PromiseActionReaction.cs
56 lines
| 2.0 KiB
| text/x-csharp
|
CSharpLexer
/ Implab / PromiseActionReaction.cs
cin
|
r247 | using System; | |
using System.Diagnostics; | |||
namespace Implab { | |||
class PromiseActionReaction : PromiseReaction { | |||
readonly Deferred m_next; | |||
cin
|
r248 | public IPromise Promise { | |
get { return m_next.Promise; } | |||
} | |||
public PromiseActionReaction(Action fulfilled, Action<Exception> rejected, IDispatcher dispatcher) : base(dispatcher) { | |||
m_next = new Deferred(dispatcher); | |||
cin
|
r247 | if (fulfilled != null) | |
cin
|
r248 | FulfilHandler = PromiseHandler.Create(fulfilled, m_next); | |
cin
|
r247 | ||
if (rejected != null) | |||
cin
|
r248 | RejectHandler = PromiseHandler.Create(rejected, m_next); | |
cin
|
r247 | } | |
cin
|
r248 | public PromiseActionReaction(Func<IPromise> fulfilled, Func<Exception, IPromise> rejected, IDispatcher dispatcher) : base(dispatcher) { | |
m_next = new Deferred(dispatcher); | |||
cin
|
r247 | if (fulfilled != null) | |
cin
|
r248 | FulfilHandler = PromiseHandler.Create(fulfilled, m_next); | |
cin
|
r247 | ||
if (rejected != null) | |||
cin
|
r248 | RejectHandler = PromiseHandler.Create(rejected, m_next); | |
cin
|
r247 | } | |
cin
|
r248 | public PromiseActionReaction(Action fulfilled, Func<Exception, IPromise> rejected, IDispatcher dispatcher) : base(dispatcher) { | |
m_next = new Deferred(dispatcher); | |||
cin
|
r247 | if (fulfilled != null) | |
cin
|
r248 | FulfilHandler = PromiseHandler.Create(fulfilled, m_next); | |
cin
|
r247 | ||
if (rejected != null) | |||
cin
|
r248 | RejectHandler = PromiseHandler.Create(rejected, m_next); | |
cin
|
r247 | } | |
cin
|
r248 | public PromiseActionReaction(Func<IPromise> fulfilled, Action<Exception> rejected, IDispatcher dispatcher) : base(dispatcher) { | |
m_next = new Deferred(dispatcher); | |||
if (fulfilled != null) | |||
FulfilHandler = PromiseHandler.Create(fulfilled, m_next); | |||
cin
|
r247 | ||
cin
|
r248 | if (rejected != null) | |
RejectHandler = PromiseHandler.Create(rejected, m_next); | |||
} | |||
cin
|
r247 | ||
protected override void DefaultReject(Exception reason) { | |||
m_next.Reject(reason); | |||
} | |||
protected override void DefaultResolve() { | |||
m_next.Resolve(); | |||
} | |||
} | |||
} |