diff Implab/PromiseT.cs @ 135:656815cb7147 v2

Fixed chaining of promises with 'Then' method
author cin
date Fri, 13 Feb 2015 02:08:01 +0300
parents 671f60cd0250
children f75cfa58e3d4
line wrap: on
line diff
--- a/Implab/PromiseT.cs	Wed Feb 11 02:12:15 2015 +0300
+++ b/Implab/PromiseT.cs	Fri Feb 13 02:08:01 2015 +0300
@@ -349,18 +349,24 @@
 
         public IPromise<T2> Then<T2>(Func<T, T2> mapper, Func<Exception, T2> error, Func<T2> cancel) {
             var promise = new Promise<T2>();
+            if (mapper != null)
+                promise.On(Cancel, PromiseEventType.Cancelled);
             AddHandler(new RemapDescriptor<T2>(mapper, error, cancel, promise));
             return promise;
         }
 
         public IPromise<T2> Then<T2>(Func<T, T2> mapper, Func<Exception, T2> error) {
             var promise = new Promise<T2>();
+            if (mapper != null)
+                promise.On(Cancel, PromiseEventType.Cancelled);
             AddHandler(new RemapDescriptor<T2>(mapper, error, null, promise));
             return promise;
         }
 
         public IPromise<T2> Then<T2>(Func<T, T2> mapper) {
             var promise = new Promise<T2>();
+            if (mapper != null)
+                promise.On(Cancel, PromiseEventType.Cancelled);
             AddHandler(new RemapDescriptor<T2>(mapper, null, null, promise));
             return promise;
         }