tailslide / fluxor-persist Goto Github PK
View Code? Open in Web Editor NEWFluxor-persist is a library to persist Fluxor states.
License: MIT License
Fluxor-persist is a library to persist Fluxor states.
License: MIT License
I upgraded my blazor application to .net6, now following subscription is not working any more:
ActionSubscriber.SubscribeToAction<InitializePersistMiddlewareResultSuccessAction>(this, result => { });
Look's like it's never triggered.
Is it possible to upgrade the package, that it works with .net6?
Thanks!
Hi,
I've got a strange issue.
The middleware was not able to rehydrate simple object
... The JSON value could not be converted to Sudoku.Store.Counter.StateCounter ...
I succeeded to overcome the issue by updating the method LocalStateStorage.GetStateJsonAsync
The problem seems coming from await LocalStorage.GetItemAsStringAsync(statename)
That I replaced successfully by await LocalStorage.GetItemAsync<string>(statename)
Sincerely,
Hi, This is a really great library and i feel like it will solve my issue just need one affirmation. This is more of a question really. I am starting out on blazor and am using fluxor for my state management. Everything works fine but when i navigating away from a component i loose all the state, is that expected behavior when using fluxor? and i mean navigating away and not a page refresh. I believe in blazor on navigating away the component is usually destroyed and a new one created meaning all state will be lost. I figured Fluxor will help maintain the state but it seems thats not the case or there could be something i am missing?
regards
Is your feature request related to a problem? Please describe.
I'm using LocalStorage to persist my data and I've got an issue where I need a certain feature's state to be loaded before any others because it is used in the key of the others. Example: ZState needs to load before "LastUserSelectionState" because I'm storing things with keys like: "{authorized user}\{ZState.Value}\{LastUserSelection.Value}".
Currently, the features are loaded in alphabetical order by feature type full name. So ZState would load after LastUserSelection and therefore doesn't load LastUserSelection correctly.
Describe the solution you'd like
It would be great to have a feature priority level attribute. If I have a [FeatureState] class or record, I could have another attribute like [FeatureState, PriorityLoad(1)] where "1" denotes the priority level highest (1) to lowest (int max value).
Describe alternatives you've considered
The only other solution I can think of here is to name them alphabetically to prioritize them which is a naming convention snafu and a special rule that has to be remembered/documented.
Additional context
The issue code:
Is your feature request related to a problem? Please describe.
I'm currently sharing the same codebase between a blazor and Xamarin app. The MVVM library uses fluxor to do the state management, but as fluxor persist targets net6 this can't be added to the netstandard shared library
Describe the solution you'd like
Fluxor.Persist should target netstandard2.0, same as Fluxor itself
Describe alternatives you've considered
Of course when .NET maui is released (net6.0) this will not be an issue for mobile apps
I am using Blazor Server and followed the instructions on setting this up e.g. this was added to main, where I essentially copy the sample LocalStateStorage class
builder.Services.AddBlazoredLocalStorage();
builder.Services.AddScoped<IStringStateStorage, LocalStateStorage>();
builder.Services.AddScoped<IStoreHandler, JsonStoreHandler>();
builder.Services.AddFluxor(config =>
{
config
.ScanAssemblies(typeof(Program).Assembly)
#if DEBUG
.UseReduxDevTools(rdt =>
{
rdt.Name = "MY APP";
})
#endif
.UsePersist()
;
});
When I start my app, I see the error at the top of the page "Attempting to reconnect to the server: 1 of 8" the console has the following error "[2023-09-10T17:05:49.166Z] Error: Connection disconnected with error 'Error: Server returned an error on close: Connection closed with an error.'.
log @ blazor.server.js:1
"
The page eventually loads and I can see my view, data has loaded, store is created in localstorage. I now click on a detail page for an item or navigate to another page etc. same error etc.
Am I missing something for the setup? Does this work with Blazor Server vs Blazor WASM? I am using "Fluxor Version="5.9.1" and Blazored.LocalStorage" Version="4.4.0"
This is a great library btw and I've been using it extensively.
Probably a little too extensively ๐ , because I'm having issues with the smaller local storage limits on mobile devices - or maybe the smaller limits on individual entries in local storage?
This is something I'm happy to have a go at when I have the time, but I wanted to get your quick take first:
Do you think there'd be any issues implementing this with persisting to IndexedDB instead of local storage?
I've been using your example implementation of IStringStateStorage but I assume it would just be a matter of implementing this to target IndexedDB? I've not used IndexedDB before and I'm not sure if it can take the sort of 'Bulk Insert' that might be necessary to be sufficiently performant.
But from this answer, it seems like it should be possible, at least back in 2018: Stack overflow answer
So it looks doable. But before I give it a go, have you any thoughts I should consider?
Many thanks
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.