mrpmorris / Fluxor

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

Dispatch from Polly #470

Closed Hantse closed 6 months ago

Hantse commented 7 months ago

Hello.

I try to implement in my application a generic handler for HTTPClient. I used Polly and a Policy to dispatch an action (for 200, 400 etc) the main flow work well, but action dispatched in the Polly, it's not catch by reducers, any idea?

Kr,

mrpmorris commented 7 months ago

I don't know why, but reducers should never need Polly.

Your reducer code should always work. If it fails then it's because of a bug that needs fixing. Polly is for transitive errors like network outages - your reducers definitely shouldn't be doing stuff with the network.

If you call it to external resources then you can use Polly, but this should never be done in a reducer. It should either be in your application code or an Effect (if you choose to use them).

Hantse commented 7 months ago

Hello, Thx for response.

The dispatcher is call from retry policy from Polly. To dispatch status on page and display message globally on layout.

But, event dispatch from Polly, it's never received by Reducers.

Kr,

mrpmorris commented 7 months ago

Please show me some code

mrpmorris commented 6 months ago

Closing this. Let me know if you have something for me.