Last change
on this file since 256 was
256,
checked in by hendrikvanantwerpen, 13 years ago
|
Reworked project structure based on REST interaction and Dojo library. As
soon as this is stable, the old jQueryUI branch can be removed (it's
kept for reference).
|
File size:
737 bytes
|
Line | |
---|
1 | dojo.provide("dojox.lang.async.event"); |
---|
2 | |
---|
3 | // Source of Deferred for events |
---|
4 | |
---|
5 | (function(){ |
---|
6 | var d = dojo, event = dojox.lang.async.event; |
---|
7 | |
---|
8 | event.from = function(src, name){ |
---|
9 | return function(){ |
---|
10 | var h, cancel = function(){ |
---|
11 | if(h){ |
---|
12 | d.disconnect(h); |
---|
13 | h = null; |
---|
14 | } |
---|
15 | }, |
---|
16 | x = new d.Deferred(cancel); |
---|
17 | h = d.connect(src, name, function(evt){ |
---|
18 | cancel(); |
---|
19 | x.callback(evt); |
---|
20 | }); |
---|
21 | return x; |
---|
22 | }; |
---|
23 | }; |
---|
24 | |
---|
25 | event.failOn = function(src, name){ |
---|
26 | return function(){ |
---|
27 | var h, cancel = function(){ |
---|
28 | if(h){ |
---|
29 | d.disconnect(h); |
---|
30 | h = null; |
---|
31 | } |
---|
32 | }, |
---|
33 | x = new d.Deferred(cancel); |
---|
34 | h = d.connect(src, name, function(evt){ |
---|
35 | cancel(); |
---|
36 | x.errback(new Error(evt)); |
---|
37 | }); |
---|
38 | return x; |
---|
39 | }; |
---|
40 | }; |
---|
41 | })(); |
---|
Note: See
TracBrowser
for help on using the repository browser.