Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Peter Morris
    @mrpmorris
    So you always have to keep whatever you load
    And that's an even bigger problem if the server deletes an entity with no way of informing clients
    It's best to have duplicate state that is kept in sync, so you can reset it when the user navigates to another part of the app
    Imho
    Andrzej Bakun
    @Andrzej2_gitlab
    @mrpmorris Thanks, I have to play around with this idea, but I think I get it.
    Andrzej Bakun
    @Andrzej2_gitlab
    Sooo...injecting to Reducers is a no-no. What about Feature? Is there any recomendation against it and if so, why?
    camelCaseSharp
    @camelCaseSharp
    @mrpmorris Do you have any thoughts on the possible functional overlap between Fluxor and the data caching provided by HotChocolate's client library StrawberryShake?
    Peter Morris
    @mrpmorris
    @Andrzej2_gitlab features are just descriptors for state, they shouldn't have logic.
    If you need dependencies, then you need an Effect
    @camelCaseSharp on account I've never heard of it, no :)
    Andrzej Bakun
    @Andrzej2_gitlab
    Ok, let me tell you my issue then. I am trying still to do the state preservation. I made changes to the project by @Tailslide, and it is working generally fine. Except, I do not like the fact that before my stored state is restored, I first see initial state. In my original solution that I posted to mrpmorris/Fluxor#183 this problem does not exist, because I inject my storeage to feature and it initializes to preserved state (unless nothing found then initilalized to default). Using middleware it seems to always initialize to first initial and then to preserved.
    Also, is there any registry (similar to IStore.Features) that contains mapping between state (type/type name but not feature name) and feature? I need it because in the lib, I have a black/whitelist that I would prefereably like to initialize it with nameof(StateClassName) instead of magicString_FeatureName.
    camelCaseSharp
    @camelCaseSharp
    @mrpmorris Sorry I should have provided more context. HotChocolate is a .Net based GraphQL server/library and seems to have the most developer buzz in the .Net/GraphQL space. StrawberryShake (SS) is HotChocolate's .Net client-side GraphQL library and SS is often demonstrated running on Blazor WebAssembly. The client-side SS library does more than just submit GraphQL queries to fetch data, it also incorporates optional caching. In my CQRS oriented Blazor apps the use of Fluxor is a given. The new GraphQL based cache facility is causing me an architectural headache because I see a functional overlap.
    Could you load state there and store it in an AsyncLocal to pick up from your feature?
    @camelCaseSharp I know nothing about it so can't comment. If you have specific problems then post those here
    Andrzej Bakun
    @Andrzej2_gitlab
    @mrpmorris I already load the state in the initialization. But I haven't tried AsyncLocal. I am going to give it a shoot. Thanks!
    Peter Morris
    @mrpmorris
    I don't recall the order of execution, but you should be able to load state before it renders
    Even if you only conditionally render your main layout content after it has had a chance to load
    That might be the answer, because Blazor doesn't wait for async to finish, it just goes on and renders immediately
    Andrzej Bakun
    @Andrzej2_gitlab
    I did a bit more digging, and this problem that I see only happens in blazor server. At first I thought the problem was with prerendering, but event with prerendering switched off, I still see the initial values.
    I was also digging into AsyncLocal - I did not have to use it before so this is new ground for me. But based on what I read and what you suggested, it seems to me that I should expose the AsyncLocal as a public static variable in the middleware and use that in feature - is that correct?
    Peter Morris
    @mrpmorris
    Yes. Read state to async local, have the feature return that as initial state
    Andrzej Bakun
    @Andrzej2_gitlab
    @mrpmorris I think I tried what you suggested but it did not work. My AsyncLocal had null value. So I debuged and the feature's GetInitialState is executed before even the middleware is instantiated (not mentioning executing the middleware's InitializeAsync). Actually, my blazor server page was already rendered and viewed on the browser, before debugger stopped in the first line of InitializeAsync. So I do not think this is going to work...
    Peter Morris
    @mrpmorris
    Server-side or WASM?
    I think your best option is to have something in your main layout that renders a "Please wait" until you've restored state
    and then renders contents
    Andrzej Bakun
    @Andrzej2_gitlab
    As I mentioned before, this problem applies ony to Server-side. I know I can show a loading screen, but I think this is just hiding a problem that can be easily solved with service injection. So I will ask again - what are the dangers of injecting my persisted store to the features? This would be a service strictly made for fluxor. I know I can and very likely I will do that, but if I know the dangers maybe I can better protect myself against them (dangers other than coming from bugs in my injected service or service not being registered with DI).
    Peter Morris
    @mrpmorris
    I can only suggest you experiment and see what happens
    Andrzej Bakun
    @Andrzej2_gitlab
    So I extended theFeatureclass to inject my persisted store and initalize the state either to value exisiting in the store or to the default. For the time being it seems to be working as expected and I do not get the initial values shown in the server side. Thanks for your help!
    William Roseberry
    @RoseberryPi
    I don't have a chance to test this right now but does Fluxor keep state across tabs?
    Peter Morris
    @mrpmorris
    No
    Blazor gives each tab its own Scope
    William Roseberry
    @RoseberryPi
    @mrpmorris thanks!
    Andrzej Bakun
    @Andrzej2_gitlab
    @RoseberryPi You could persist state and then implement some extra logic to figure out which state should be restored from your persisted store.
    William Roseberry
    @RoseberryPi
    @Andrzej2_gitlab How would that be done?
    Peter Morris
    @mrpmorris
    Are you saying you want the same state in multiple tabs that are open at the save time?
    William Roseberry
    @RoseberryPi
    @mrpmorris That was the hope.
    Tailslide
    @Tailslide
    You could persist state to localstorage then listen for localstorage changes to refresh the state. I'd avoid doing multiple tabs if possible though.
    William Roseberry
    @RoseberryPi
    Was trying to avoid using webstorage like that. It's no biggie though.
    Tailslide
    @Tailslide
    You could persist back to the server and have some kind of state change notification using SignalR or something. Sounds like a lot of work.
    Andrzej Bakun
    @Andrzej2_gitlab
    @RoseberryPi you could use @Tailslide 's lib for persisting state fluxor-persist. You want to do this in wasm or server-side?
    Peter Morris
    @mrpmorris
    See the accepted answer here. You could broadcast actions https://stackoverflow.com/questions/28230845/communication-between-tabs-or-windows
    Tailslide
    @Tailslide
    Seems to not work on safari unfortunately.
    Peter Morris
    @mrpmorris
    Shame
    William Roseberry
    @RoseberryPi
    This is all WASM @Andrzej2_gitlab I'll check out the library!
    Tailslide
    @Tailslide
    In redux I could make a reducer that generically handles all actions.. is something like that possible in Fluxor? I'd like to have a single 'busy' state for the whole application based on the loading flag of all actions in progress.
    Peter Morris
    @mrpmorris
    A reducer for a base class will handle all descendants
    Base Action class
    Tailslide
    @Tailslide
    That will be perfect thanks