private void AddPromiseHandles(IPromiser resultPromise, Action resolveHandle, Action <Exception> rejectHandle, Action <float> notifyHandle) { switch (CurrentState) { case PromiseState.Pending: if (resolveHandle != null) { _resolveHandlers.Add(new ResolveInvoker(resultPromise, resolveHandle)); } if (rejectHandle != null) { _rejectHandlers.Add(new RejectInvoker(resultPromise, rejectHandle)); } if (notifyHandle != null) { _processHandlers.Add(new NotifyInvoker(resultPromise, notifyHandle)); } break; case PromiseState.Rejected: try { rejectHandle.Invoke(_rejectedValue); } catch (Exception e) { resultPromise.Reject(e); } break; case PromiseState.Resolved: try { resolveHandle.Invoke(); } catch (Exception e) { resultPromise.Reject(e); } break; default: throw new ArgumentOutOfRangeException(); } }
public RejectInvoker(IPromiser rejector, Action <Exception> rejectHandler) { Rejector = rejector; RejectHandler = rejectHandler; }
public ResolveInvoker(IPromiser rejector, Action resolvedHandler) { Rejector = rejector; ResolvedHandler = resolvedHandler; }
public NotifyInvoker(IPromiser rejector, Action <float> notifyHandler) { Rejector = rejector; NotifyHandler = notifyHandler; }