##// END OF EJS Templates
working on promises
working on promises

File last commit:

r247:fb70574741a1 v3
r247:fb70574741a1 v3
Show More
PromiseReaction.cs
44 lines | 1.1 KiB | text/x-csharp | CSharpLexer
/ Implab / PromiseReaction.cs
cin
missing files
r246 using System;
namespace Implab {
cin
working on promises
r247 abstract class PromiseReaction : IResolvable {
readonly IDispatcher m_dispatcher;
protected PromiseReaction(IDispatcher dispatcher) {
m_dispatcher = dispatcher;
}
cin
missing files
r246
cin
working on promises
r247 protected abstract bool HasFulfilHandler {
get;
}
cin
missing files
r246
cin
working on promises
r247 protected abstract bool HasRejectHandler {
get;
}
cin
missing files
r246
public void Reject(Exception error) {
cin
working on promises
r247 if (!HasRejectHandler)
DefaultReject(error);
else if (m_dispatcher != null)
m_dispatcher.Enqueue(() => RejectImpl(error));
else
RejectImpl(error);
cin
missing files
r246 }
public void Resolve() {
cin
working on promises
r247 if (!HasFulfilHandler)
DefaultResolve();
else if (m_dispatcher != null)
m_dispatcher.Enqueue(ResolveImpl);
else
ResolveImpl();
cin
missing files
r246 }
cin
working on promises
r247
protected abstract void ResolveImpl();
protected abstract void RejectImpl(Exception reason);
protected abstract void DefaultResolve();
protected abstract void DefaultReject(Exception reason);
cin
missing files
r246 }
}