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