public IPromise <T> ThenRace <T>(Func <IEnumerable <IPromise <T> > > chain) { return(Then(() => Promise <T> .Race(chain()))); }
private Promise Then(Func <IPromise> onFulfilled, Action <Exception> onRejected, Promise result) { return (Apply( result, () => { if (onFulfilled == null) { result.Resolve(); } else { onFulfilled().Then(() => result.Resolve(), result.Reject); } }, error => { onRejected(error); result.Reject(error); })); }
public IPromise <IEnumerable <T> > ThenAll <T>(Func <IEnumerable <IPromise <T> > > chain) { return(Then(() => Promise <T> .All(chain()))); }
private IPromise <TNext> Then <TNext>(Func <IPromise <TNext> > onFulfilled, Action <Exception> onRejected, Promise <TNext> result) { return (Apply( result, () => onFulfilled().Then(nextValue => result.Resolve(nextValue), result.Reject), error => { onRejected(error); result.Reject(error); })); }