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
    Yeah, you can have as many IState<T> injected as you like and they will all be subscribed to automatically
    and unsubscribed when disposed
    Jorn Vanloofsvelt
    @JVanloofsvelt
    @mrpmorris I'm new to the Flux pattern and there's so much info and opinions around. Can you tell me, when using Fluxor, if I want to do things like debounce actions, replace/cancel an active Task when a new action is dispatched; would I need something similar to Redux-Observables?
    Matthias-Claes
    @Matthias-Claes
    I'm currently trying to create an autocomplete search using MudBlazor's AutoComplete component and the SearchFuncwhich I use to fire the search query requires me to return a Task<IEnumerable<T>>. Since I'm using Flux I'm returning the result of the query using an action. Is there any way that I can wait on the success action in my form so the autocomplete doesn't return results before they are actually there?
    private async Task<IEnumerable<Animal>> OnAutocompleteSearch(string query)
            {
                Dispatcher.Dispatch(new AutocompleteSearchAction(query));
    
                SubscribeToAction<AutocompleteSearchSuccessAction>(async action =>
                {
                    return action.animals; // Error ofc it is not returning a Task<IEnumerable<Animal>>
                });
            }
    Haytam Zanid
    @zHaytam
    What's the advantage of using Flux for this?
    You don't really need the autocomplete results in the state, I don't find it beneficial
    Jorn Vanloofsvelt
    @JVanloofsvelt
    @zHaytam Interesting point. Indeed, I can imagine something like autocomplete results don't need to be stored in the state store.
    Peter Morris
    @mrpmorris
    I use state for "saved" state
    I quote it because I don't mean saved on the DB
    But kind of "committed"
    or "Yes, I am confirming that is what I now want my state to be"
    So editing data etc I would only reduce into state when the user clicks Save
    Unless you are on some screen where you want to slide sliders etc and have all sorts of things update on the screen at the same time
    Haytam Zanid
    @zHaytam
    For some reason RoutingMiddleware isn't found
    <PackageReference Include="Fluxor.Blazor.Web" Version="3.9.0" />
    UseRouting() works
    Peter Morris
    @mrpmorris
    Middleware has to be explicitly included
    Maxim Crabbé
    @MaximCrabbe
    @zHaytam I think you are right about the autocomplete data not being put in the state, the only thing I 'dislike' about it, is that he ll be putting HTTP call logic in the component or a service, while mostly 80% of other HTTP calls will be started in effects (or they should maybe the http calls should also be put in services I assume and not directly in effects :)? )
    Haytam Zanid
    @zHaytam
    I feel like that's fine, having a few http calls in some specific components for specific things that aren't related to the state is okay
    Peter Morris
    @mrpmorris
    If you aren't going to have another UI then it's not really a problem
    If you are going to have a Blazor UI and a XAML UI then I'd put all behaviour in the store
    Borislav Nikolov
    @Sesi0

    hey @mrpmorris,

    I have a problem when adding Fluxor to a Blazor WASM project.

    image.png
    Borislav Nikolov
    @Sesi0
    Downgraded to 5.0.0 and it seems to be ok.
    Borislav Nikolov
    @Sesi0
    @mrpmorris is there a way to call actions before other components are init?
    Borislav Nikolov
    @Sesi0
    Nevermind I just found SubscribeToAction which worked perfectly for my usage.
    Borislav Nikolov
    @Sesi0
    I think it should be documented in the Blazor docs it is pretty good feature.
    Peter Morris
    @mrpmorris
    @Sesi0 Was it Blazor 5.1 that had this problem, but it worked in 5.0?
    Borislav Nikolov
    @Sesi0
    @mrpmorris I tried again to update it and it works maybe it was due to LiveSharp package. But the strange thing is it worked with LiveSharp when Fluxor was not implemented. I will just continue without hot reload.
    Peter Morris
    @mrpmorris
    LiveSharp can cause those kinds of probles
    Haytam Zanid
    @zHaytam
    @mrpmorris How would I go about extracting user info from local storage back into the state when visiting the app again?
    Borislav Nikolov
    @Sesi0
    @zHaytam for example you store the culture in local storage and on visiting the app you want to load the language based on this culture?
    Haytam Zanid
    @zHaytam
    yes
    Borislav Nikolov
    @Sesi0
    I initialize the store in App.razor.cs and after this, I dispatch the actions to initialize the store. (LoadThemeAction, LoadCultureAction and etc.)
    I will give you an example
    image.png
    App.razor.cs
    And in one component I need to get some state-based properties in the back code (for example SelectLanguage.razor.cs)
    image.png
    I subscribe to the action which holds the new theme, change my fields in the component and call StateHasChanged()
    Haytam Zanid
    @zHaytam
    Oh, got it, thank you for the examples!
    Borislav Nikolov
    @Sesi0
    @zHaytam no problem, btw this was also my question when I asked you when I refresh the browser.
    Peter Morris
    @mrpmorris
    An effect that listens for StoreInitializedAction. Reads state, then dispatches an action with that state in
    Haytam Zanid
    @zHaytam
    Seems like StoreInitializedAction gets triggered even when navigating to another page
    Is that normal?
    Actually, navigating to another page seems to reload the whole page
    Nevermind, it does that when the page doesn't exist
    Haytam Zanid
    @zHaytam
    @mrpmorris Would WASM trimming break the app with Fluxor?
    Matthias-Claes
    @Matthias-Claes

    I'm currently trying to pull all my action related stuff into a StateFacade but I ran into a problem where my component needs to wait for data to load. I'm currently using SubscribeToAction to wait for my success actions but I'm wondering if there is a way to also pull this into the StateFacade.

    I need my results to fill the model for my EditContext in my component.

    Anyone got any ideas for this?

    Peter Morris
    @mrpmorris
    @zHaytam no. Trimming only affects MS assemblies