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

Add method to clear the handler list #21

Open
rafael-biz opened this issue Mar 26, 2019 · 2 comments
Open

Add method to clear the handler list #21

rafael-biz opened this issue Mar 26, 2019 · 2 comments

Comments

@rafael-biz
Copy link

Can you add a method on the Hub class to clear the handler list?

@upta
Copy link
Owner

upta commented Mar 26, 2019

Would be simple enough to add, though I'm curious about the use-case. In general I'd think you'd want individual consumers cleaning up after themselves using the Unsubscribe methods instead of having some other process pull it out from under them; feel like a way to introduce hard-to-track bugs.

If there's a compelling use-case, though, I'm not opposed

@rafael-biz
Copy link
Author

Agreed. Consumers must unsubscribe themselves using the Unsubscribe methods.

I just thought that a cleaning method could be called as a last resource to prevent memory leaks. But I found out in the source code that the handler list keeps a weak reference and that should not be a problem. Also, the unit testing covers the garbage collector very well.

I also agree that it could introduce hard-to-track bugs. But it is fine if we just put it in the Hub class without an extension.

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

No branches or pull requests

2 participants