mrpmorris / Fluxor

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

Support for IAsyncDisposable components #324

Closed rainerllera closed 4 months ago

rainerllera commented 2 years ago

Hey @mrpmorris , first of all thank you so much for your work on Fluxor, It is a great tool!

This is more of a feature request I think? So here it goes:

Sometimes Components need to be disposed asynchronously, like when you need to post some value back to the server when exiting the component, unsubscribe from SignalR groups gracefully etc. Right now, the blazor renderer expects components to implement either IAsyncDisposable or IDisposable when disposing them, but favors the asynchronous method (i.e. it only calls either DisposeAsync or Dispose, in that order, not both). See this.

Now quite a few of my components inherit from FluxorComponent, and I usually dispose things by overriding Dispose(bool disposing), but since the framework has that limitation/constraint explained above, whenever I need to implement IAsyncDisposable I need to remember to manually call Dispose() in there, because the Renderer won't do it.

Not calling dispose manually there will result in a supposedly dead (disposed) component (for the renderer) but a Fluxor component with active State/Action subscriptions. It's kind of a weird scenario where you would expect your component to be disposed, but it is not.

Anyways, thought maybe providing some similar pattern to the Dispose(disposing) but in an async fashion could be useful to others as well. Again, thanks for your work man. Cheers!

PS: happy to submit a PR if you find it useful.

mrpmorris commented 2 years ago

Hiya

Please submit a PR based off release/5.5 and we can discuss the implementation :)

mrpmorris commented 1 year ago

Fixed in 6.0

alexandrutatarciuc commented 8 months ago

@mrpmorris Any news on when will this be released? Looks like changes were made almost a year ago, however, I can see that FluxorComponent still implements IDisposable.

mrpmorris commented 4 months ago

I'm going through the motions now. Checking github issues to see what I should include.