247
|
1 using System;
|
|
2 using System.Diagnostics;
|
|
3
|
|
4 namespace Implab {
|
|
5 class PromiseActionReaction : PromiseReaction {
|
|
6
|
|
7 readonly Deferred m_next;
|
|
8
|
248
|
9 public IPromise Promise {
|
|
10 get { return m_next.Promise; }
|
|
11 }
|
|
12
|
|
13 public PromiseActionReaction(Action fulfilled, Action<Exception> rejected, IDispatcher dispatcher) : base(dispatcher) {
|
|
14 m_next = new Deferred(dispatcher);
|
247
|
15 if (fulfilled != null)
|
248
|
16 FulfilHandler = PromiseHandler.Create(fulfilled, m_next);
|
247
|
17
|
|
18 if (rejected != null)
|
248
|
19 RejectHandler = PromiseHandler.Create(rejected, m_next);
|
247
|
20 }
|
|
21
|
248
|
22 public PromiseActionReaction(Func<IPromise> fulfilled, Func<Exception, IPromise> rejected, IDispatcher dispatcher) : base(dispatcher) {
|
|
23 m_next = new Deferred(dispatcher);
|
247
|
24 if (fulfilled != null)
|
248
|
25 FulfilHandler = PromiseHandler.Create(fulfilled, m_next);
|
247
|
26
|
|
27 if (rejected != null)
|
248
|
28 RejectHandler = PromiseHandler.Create(rejected, m_next);
|
247
|
29 }
|
|
30
|
248
|
31 public PromiseActionReaction(Action fulfilled, Func<Exception, IPromise> rejected, IDispatcher dispatcher) : base(dispatcher) {
|
|
32 m_next = new Deferred(dispatcher);
|
247
|
33 if (fulfilled != null)
|
248
|
34 FulfilHandler = PromiseHandler.Create(fulfilled, m_next);
|
247
|
35
|
|
36 if (rejected != null)
|
248
|
37 RejectHandler = PromiseHandler.Create(rejected, m_next);
|
247
|
38 }
|
|
39
|
248
|
40 public PromiseActionReaction(Func<IPromise> fulfilled, Action<Exception> rejected, IDispatcher dispatcher) : base(dispatcher) {
|
|
41 m_next = new Deferred(dispatcher);
|
|
42 if (fulfilled != null)
|
|
43 FulfilHandler = PromiseHandler.Create(fulfilled, m_next);
|
247
|
44
|
248
|
45 if (rejected != null)
|
|
46 RejectHandler = PromiseHandler.Create(rejected, m_next);
|
|
47 }
|
247
|
48
|
|
49 protected override void DefaultReject(Exception reason) {
|
|
50 m_next.Reject(reason);
|
|
51 }
|
|
52
|
|
53 protected override void DefaultResolve() {
|
|
54 m_next.Resolve();
|
|
55 }
|
|
56 }
|
|
57 } |