Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for IAsyncDisposable components #324

Closed
rainerllera opened this issue Jun 19, 2022 · 4 comments
Closed

Support for IAsyncDisposable components #324

rainerllera opened this issue Jun 19, 2022 · 4 comments
Milestone

Comments

@rainerllera
Copy link

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
Copy link
Owner

Hiya

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

@mrpmorris
Copy link
Owner

Fixed in 6.0

@alexandrutatarciuc
Copy link

@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 mrpmorris reopened this Oct 30, 2023
@mrpmorris
Copy link
Owner

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

dmitry-pavlov added a commit to dmitry-pavlov/Fluxor that referenced this issue Mar 22, 2024
* Remove support for obsolete versions of .NET (mrpmorris#385)

* Change IDisposable to IAsyncDisposable (Fixes mrpmorris#324)

* ReduxDevTools should not call UseRouting (Fixes mrpmorris#360) (mrpmorris#388)

* Remove UseRouting from UseReduceDevTools

* Allow action filtering on redux dev tools (fixes mrpmorris#383) (mrpmorris#389)

* Support action filtering in Redux Dev Tools

* Add unit tests

* Remove Newtonsoft.Json (Fixes mrpmorris#386) (mrpmorris#392)

* Remove dependency on Newtonsoft.Json

* Remove support for obsolete versions of .NET (mrpmorris#385)

* Change IDisposable to IAsyncDisposable (Fixes mrpmorris#324)

* ReduxDevTools should not call UseRouting (Fixes mrpmorris#360) (mrpmorris#388)

* Remove UseRouting from UseReduceDevTools

* Allow action filtering on redux dev tools (fixes mrpmorris#383) (mrpmorris#389)

* Support action filtering in Redux Dev Tools

* Add unit tests

* Remove Newtonsoft.Json (Fixes mrpmorris#386) (mrpmorris#392)

* Remove dependency on Newtonsoft.Json

* Allow action filtering on redux dev tools (fixes mrpmorris#383) (mrpmorris#389)

* Support action filtering in Redux Dev Tools

* Add unit tests

* Bump Swashbuckle.AspNetCore.SwaggerUI

Bumps [Swashbuckle.AspNetCore.SwaggerUI](https://github.com/domaindrivendev/Swashbuckle.AspNetCore) from 6.3.0 to 6.4.0.
- [Release notes](https://github.com/domaindrivendev/Swashbuckle.AspNetCore/releases)
- [Commits](domaindrivendev/Swashbuckle.AspNetCore@v6.3.0...v6.4.0)

---
updated-dependencies:
- dependency-name: Swashbuckle.AspNetCore.SwaggerUI
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>

* Deadlock mrpmorris#474 (mrpmorris#476)

* Add lock conflict test
* Alternate locking approach
* Update .net versions

* Eliminate deadlock when executing an action from IDispatcher.ActionDispatched on a different thread mrpmorris#474 (mrpmorris#477)

* Update SourceLink
* Fix flaky tests in ThrottledInvoker
* Execute feature callbacks outside lock()

* Have ThrottledInvoker re-enter if the timer executes too soon.

* Have test ensure the execution window is within (ThrottleWindowMs) and (ThrottleWindowMs* 2)

* Change parameter name from action to throttledAction in test.

* Don't test for too long, only too short.

* Task.Yield to ensure fire-and-forget action logging has time to complete

* Update throttling tests

* Update throttling test comments

* Rewrite ThrottledInvoker to not use Timers

* Source formatting

* Make throttled invoker disposable

* Call ThrottledInvoker.Dispose  from Blazor libraries

* ThrottledInvoke.Dispose tests

* Change style of unit test

* Remove race condition from test

* Change test timings

* Spelling error

* Use IAsyncLifetime instead of using Task.Wait()

* Code tidy

* Remove NCrunch file

* Ignore *ncrunch*

* Use TimeSpan instead of int MS

* 6.0-Beta1

* Fix errors in tests detected by NCrunch.

* Unit tests for navigation fragments

* Rename UrlComparer.SameAs to UrlComparer.AreEqual

* Delete TestNavigationManager

* Add a note to Releases.md about mrpmorris#455

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: Peter Morris <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants