mrpmorris / Fluxor

Fluxor is a zero boilerplate Flux/Redux library for Microsoft .NET and Blazor.
MIT License
1.23k stars 139 forks source link

v5.4 introduced a breaking change, which may also have a bug #333

Closed asalvo closed 2 years ago

asalvo commented 2 years ago

The change implemented for #299 introduced a breaking change for my code.

@mrpmorris: The subscribe is really for grabbing hold of objects that don't get reduced into state. What are you trying to achieve? This is what I've always done. Specifically when fetching domain entities for editing, @mrpmorris has always said, don't store the entity in the state :)

If you run the ActionSubscriber tutorial, when you click the Edit button (to edit a customer), you will get an blazor error unhandled exception rendering component: EditForm requires either a Model parameter, or an EditContext parameter, please provide one of these. However the form data looks correct, and you can edit and save. This is exactly what is happening in my app, I get an error after my entity is loaded, but the form looks and functions OK.

What I believe is happening is that:

mrpmorris commented 2 years ago

The original code basically hid what was an error. The UI should present based on actual state rather than what it assumes it is. I have fixed that in the demo, thanks!

@if (State.Value.IsLoading || State.Value.IsSaving || EditCustomerDto is null)
{
    if (State.Value.IsLoading)
    {
        <h4>Loading...</h4>
    }
    else
    {
        <h4>Saving customer: @EditCustomerDto?.Id @EditCustomerDto?.Name</h4>
    }
}
else
{
    <EditForm Model=@EditCustomerDto>