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

fix(parent_topic): Be able to unsubscribe all childs from giving a paren... #76

Closed
wants to merge 3 commits into from

Conversation

pipo02mix
Copy link

Implement clearing subscriptions by topic parent like this (before it was not working):

PubSub.subscribe('a', myFunc1);
PubSub.subscribe('a.b', myFunc2);
PubSub.subscribe('a.b.c', myFunc3);

PubSub.unsubscribe('a.b');
// no further notications for 'a.b' and 'a.b.c' topics
// notifications for 'a' will still get published

@mroderick
Copy link
Owner

Thank you for your pull request 👍

Please provide a failing test that only passes with your implementation in place

@pipo02mix
Copy link
Author

Indeed there is a feature more than a fix. I thought by default unsubscribe clear the current node and all its children. My proposal, is to add a extra boolean argument (false by default) allowing remove all subscriptions of the topic passed and its children topics.

PubSub.subscribe('a', myFunc1);
PubSub.subscribe('a.b', myFunc2);
PubSub.subscribe('a.b.c', myFunc3);

PubSub.unsubscribe('a.b', true);
// no further notifications for 'a.b' and 'a.b.c' topics
// with the optional second argument equals to true, all subscribers are removed for children topics
// notifications for 'a' will still get published

@mroderick
Copy link
Owner

I believe this feature was implemented with #97. Do you agree?

@pipo02mix
Copy link
Author

@mroderick Yes, it what I expected. Thanks

@pipo02mix pipo02mix closed this Oct 20, 2016
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 this pull request may close these issues.

2 participants