diff options
| author | Tristan Zur <tzur@web.web.ccwn.org> | 2014-03-27 22:27:47 +0100 |
|---|---|---|
| committer | Tristan Zur <tzur@web.web.ccwn.org> | 2014-03-27 22:27:47 +0100 |
| commit | b62676ca5d3d6f6ba3f019ea3f99722e165a98d8 (patch) | |
| tree | 86722cb80f07d4569f90088eeaea2fc2f6e2ef94 /js/dojo-1.6/dojox/lang/async/topic.js | |
Diffstat (limited to 'js/dojo-1.6/dojox/lang/async/topic.js')
| -rw-r--r-- | js/dojo-1.6/dojox/lang/async/topic.js | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/js/dojo-1.6/dojox/lang/async/topic.js b/js/dojo-1.6/dojox/lang/async/topic.js new file mode 100644 index 0000000..e0c21dc --- /dev/null +++ b/js/dojo-1.6/dojox/lang/async/topic.js @@ -0,0 +1,52 @@ +/*
+ Copyright (c) 2004-2011, The Dojo Foundation All Rights Reserved.
+ Available via Academic Free License >= 2.1 OR the modified BSD license.
+ see: http://dojotoolkit.org/license for details
+*/
+
+
+if(!dojo._hasResource["dojox.lang.async.topic"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dojox.lang.async.topic"] = true;
+dojo.provide("dojox.lang.async.topic");
+
+// Source of Deferred for topics
+
+(function(){
+ var d = dojo, topic = dojox.lang.async.topic;
+
+ topic.from = function(topic){
+ return function(){
+ var h, cancel = function(){
+ if(h){
+ d.unsubscribe(h);
+ h = null;
+ }
+ },
+ x = new d.Deferred(cancel);
+ h = d.subscribe(topic, function(){
+ cancel();
+ x.callback(arguments);
+ });
+ return x;
+ };
+ };
+
+ topic.failOn = function(topic){
+ return function(){
+ var h, cancel = function(){
+ if(h){
+ d.unsubscribe(h);
+ h = null;
+ }
+ },
+ x = new d.Deferred(cancel);
+ h = d.subscribe(topic, function(evt){
+ cancel();
+ x.errback(new Error(arguments));
+ });
+ return x;
+ };
+ };
+})();
+
+}
|
