Unsubscribe doesn't work if passed an object with channel and topic
robvon opened this issue · comments
From your code: ln 551
if (topicSubs) {
var len = topicSubs.length;
idx = 0;
// remove SubscriptionDefinition from channel list
while (idx < len) {
if (topicSubs[idx] === subDef) { <<<<<< this aint ever gonna work !!!!
topicSubs.splice(idx, 1);
break;
}
idx += 1;
}
subDef is a minimal object. topicSubs[idx] is the full sub defn. They can never point to the same object.
Consider: if (topicSubs[idx].topic === subDef.topic)
Regards
Rob
@robvon - please see https://github.com/postaljs/postal.js/wiki/postal.unsubscribe. postal.unsubscribe
is not intended to take anything other than one or more SubscriptionDefinition
instances. If you need the ability to pass a plain object with channel
and topic
in order to unsubscribe, please use https://github.com/postaljs/postal.js/wiki/postal.unsubscribeFor. Thanks!
I DID read the api doco first which although slightly ambiguous clearly states:
Quote:
// it's also possible to do this:
// (i.e. - not pass a SubscriptionDefinition)
//
postal.unsubscribe({
channel: "ui",
topic: "some.#.topic"
});
Anyway, why not just apply the patch I suggested and make it work?
Regards
Rob
From: Jim Cowart [mailto:notifications@github.com]
Sent: Tuesday, 7 July 2015 11:05 PM
To: postaljs/postal.js
Cc: Rob von Nesselrode
Subject: Re: [postal.js] Unsubscribe doesn't work if passed an object with channel and topic (#131)
@robvon https://github.com/robvon - please see https://github.com/postaljs/postal.js/wiki/postal.unsubscribe. postal.unsubscribe is not intended to take anything other than one or more SubscriptionDefinition instances. If you need the ability to pass a plain object with channel and topic in order to unsubscribe, please use https://github.com/postaljs/postal.js/wiki/postal.unsubscribeFor. Thanks!
—
Reply to this email directly or view it on GitHub #131 (comment) . https://github.com/notifications/beacon/AA9lRwQDRd9UmFNYJWfLHaaRnX6AQP1lks5oa8YWgaJpZM4FTPes.gif
@robvon That example is out of date, I will correct it. As far as why I won't just apply the suggested patch - I appreciate the suggestion, but it's the example that's incorrect (my bad for not catching that before it mislead you). I already have a method (unsubscribeFor) that covers the use case you describe. In addition I have a limited amount of time to devote to free open source work, and I don't consider this a high priority change given that the functionality is already covered. Thanks!
Fair enough. That explains the example.
It all works well enough.
R
From: Jim Cowart [mailto:notifications@github.com]
Sent: Wednesday, 8 July 2015 8:19 AM
To: postaljs/postal.js
Cc: Rob von Nesselrode
Subject: Re: [postal.js] Unsubscribe doesn't work if passed an object with channel and topic (#131)
@robvon https://github.com/robvon That example is out of date, I will correct it. As far as why I won't just apply the suggested patch - I appreciate the suggestion, but it's the example that's incorrect (my bad for not catching that before it mislead you). I already have a method (unsubscribeFor) that covers the use case you describe. In addition I have a limited amount of time to devote to free open source work, and I don't consider this a high priority change given that the functionality is already covered. Thanks!
—
Reply to this email directly or view it on GitHub #131 (comment) . https://github.com/notifications/beacon/AA9lRz9QCwVnI6mucPbksCBLpm32Bkulks5obEfmgaJpZM4FTPes.gif