Mercurial > pub > ImplabNet
diff Implab/PromiseHandler.cs @ 249:d82909310094 v3
Implab.Test moved to xunit
Complete set of PromiseHelpers (Then, Catch, Finally)
Removed obsolete types ICancellable, ICancellationToken
author | cin |
---|---|
date | Wed, 31 Jan 2018 11:28:38 +0300 |
parents | 5cb4826c2c2a |
children |
line wrap: on
line diff
--- a/Implab/PromiseHandler.cs Tue Jan 30 01:37:17 2018 +0300 +++ b/Implab/PromiseHandler.cs Wed Jan 31 11:28:38 2018 +0300 @@ -3,10 +3,10 @@ namespace Implab { class PromiseHandler { - public static Action<T> Create<T>(Action<T> handler, Deferred next) { + public static Action<T, Deferred> Create<T>(Action<T> handler) { Debug.Assert(handler != null); - return (v) => { + return (v, next) => { try { handler(v); next.Resolve(); @@ -16,10 +16,10 @@ }; } - public static Action<T> Create<T>(Func<T, IPromise> handler, Deferred next) { + public static Action<T, Deferred> Create<T>(Func<T, IPromise> handler) { Debug.Assert(handler != null); - return (v) => { + return (v, next) => { try { next.Resolve(handler(v)); } catch (Exception err) { @@ -28,10 +28,10 @@ }; } - public static Action<T> Create<T, T2>(Func<T, T2> handler, Deferred<T2> next) { + public static Action<T, Deferred<T2>> Create<T, T2>(Func<T, T2> handler) { Debug.Assert(handler != null); - return (v) => { + return (v, next) => { try { next.Resolve(handler(v)); } catch (Exception err) { @@ -40,9 +40,9 @@ }; } - public static Action<T> Create<T, T2>(Func<T, IPromise<T2>> handler, Deferred<T2> next) { + public static Action<T, Deferred<T2>> Create<T, T2>(Func<T, IPromise<T2>> handler) { Debug.Assert(handler != null); - return (v) => { + return (v, next) => { try { next.Resolve(handler(v)); } catch (Exception err) { @@ -51,10 +51,10 @@ }; } - public static Action Create(Action handler, Deferred next) { + public static Action<Deferred> Create(Action handler) { Debug.Assert(handler != null); - return () => { + return (next) => { try { handler(); next.Resolve(); @@ -64,10 +64,10 @@ }; } - public static Action Create(Func<IPromise> handler, Deferred next) { + public static Action<Deferred> Create(Func<IPromise> handler) { Debug.Assert(handler != null); - return () => { + return (next) => { try { next.Resolve(handler()); } catch (Exception err) { @@ -76,10 +76,10 @@ }; } - public static Action Create<T2>(Func<T2> handler, Deferred<T2> next) { + public static Action<Deferred<T2>> Create<T2>(Func<T2> handler) { Debug.Assert(handler != null); - return () => { + return (next) => { try { next.Resolve(handler()); } catch (Exception err) { @@ -88,9 +88,9 @@ }; } - public static Action Create<T2>(Func<IPromise<T2>> handler, Deferred<T2> next) { + public static Action<Deferred<T2>> Create<T2>(Func<IPromise<T2>> handler) { Debug.Assert(handler != null); - return () => { + return (next) => { try { next.Resolve(handler()); } catch (Exception err) {