From d653f3de29d84ac9cccbec6fef21180a99e24fb1 Mon Sep 17 00:00:00 2001 From: Jason Butz Date: Thu, 8 Sep 2016 15:36:09 -0400 Subject: [PATCH 1/2] Remove hierarchical subscriptions when unsubscribing from a topic --- src/pubsub.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pubsub.js b/src/pubsub.js index 84dbe9d..3b4c57f 100755 --- a/src/pubsub.js +++ b/src/pubsub.js @@ -21,7 +21,7 @@ https://github.com/mroderick/PubSubJS var PubSub = {}; root.PubSub = PubSub; factory(PubSub); - + }(( typeof window === 'object' && window ) || this, function (PubSub){ 'use strict'; @@ -179,7 +179,7 @@ https://github.com/mroderick/PubSubJS /*Public: Clear subscriptions by the topic */ PubSub.clearSubscriptions = function clearSubscriptions(topic){ - var m; + var m; for (m in messages){ if (messages.hasOwnProperty(m) && m.indexOf(topic) === 0){ delete messages[m]; @@ -214,7 +214,7 @@ https://github.com/mroderick/PubSubJS m, message, t; if (isTopic){ - delete messages[value]; + PubSub.clearSubscriptions(value); return; } From cd405ea8f615ec3014880de58028d384cea06a35 Mon Sep 17 00:00:00 2001 From: Jason Butz Date: Thu, 8 Sep 2016 15:58:19 -0400 Subject: [PATCH 2/2] Fix unsubscribe unit test bug --- test/test-unsubscribe.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test-unsubscribe.js b/test/test-unsubscribe.js index a22eb62..848229f 100644 --- a/test/test-unsubscribe.js +++ b/test/test-unsubscribe.js @@ -115,7 +115,7 @@ PubSub.unsubscribe(topicB); - PubSub.publishSync(topicA, TestHelper.getUniqueString()); + PubSub.publishSync(topicC, TestHelper.getUniqueString()); assert(spyA.called); refute(spyB.called);