Opened 14 years ago
Closed 14 years ago
#2071 closed enhancement (fixed)
Add useful return values to dojo.event.topic.subscribe & unsubscribe
Reported by: | Owned by: | alex | |
---|---|---|---|
Priority: | high | Milestone: | 0.9 |
Component: | Events | Version: | 0.4 |
Keywords: | Cc: | ||
Blocked By: | Blocking: |
Description
dojo.event.topic.subscribe returns undefined. It would be more useful if it returned a reference to the MethodJoinPoint? being created, so that at any time
var topicSub = dojo.event.topic.subscribe(...); topicSub.disconnect();
could be called to disconnect it.
Here's the patch required to make this change:
Index: topic.js =================================================================== --- topic.js (revision 6769) +++ topic.js (working copy) @@ -44,7 +44,7 @@
funcName: the name of the function to being registered as a listener var topic = this.getTopic(topic);
- topic.subscribe(obj, funcName);
+ return topic.subscribe(obj, funcName);
}
this.unsubscribe = function(/*String*/topic, /*Object*/obj, /*String*/funcName){
@@ -57,7 +57,7 @@
funcName: the name of the function to being unregistered as a listener var topic = this.getTopic(topic);
- topic.unsubscribe(obj, funcName);
+ return topic.unsubscribe(obj, funcName);
}
this.destroy = function(/*String*/topic){
Change History (4)
comment:1 Changed 14 years ago by
comment:2 Changed 14 years ago by
Bah! Once more, with formatting:
Index: topic.js =================================================================== --- topic.js (revision 6769) +++ topic.js (working copy) @@ -44,7 +44,7 @@ dojo.event.topic = new function(){ // funcName: // the name of the function to being registered as a listener var topic = this.getTopic(topic); - topic.subscribe(obj, funcName); + return topic.subscribe(obj, funcName); // dojo.event.MethodJoinPoint } this.unsubscribe = function(/*String*/topic, /*Object*/obj, /*String*/funcName){ @@ -57,7 +57,7 @@ dojo.event.topic = new function(){ // funcName: // the name of the function to being unregistered as a listener var topic = this.getTopic(topic); - topic.unsubscribe(obj, funcName); + return topic.unsubscribe(obj, funcName); // dojo.event.MethodJoinPoint } this.destroy = function(/*String*/topic){
comment:3 Changed 14 years ago by
Milestone: | → 0.9 |
---|
comment:4 Changed 14 years ago by
Resolution: | → fixed |
---|---|
Status: | new → closed |
looks like this happened in 0.9
Actually, this patch is better, because it has the proper documentation comments:
Index: topic.js =================================================================== --- topic.js (revision 6769) +++ topic.js (working copy) @@ -44,7 +44,7 @@ dojo.event.topic = new function(){
+ return topic.subscribe(obj, funcName); dojo.event.MethodJoinPoint?
@@ -57,7 +57,7 @@ dojo.event.topic = new function(){
+ return topic.unsubscribe(obj, funcName); dojo.event.MethodJoinPoint?