comparison 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
comparison
equal deleted inserted replaced
134:04d4c92d0f28 135:656815cb7147
347 return this; 347 return this;
348 } 348 }
349 349
350 public IPromise<T2> Then<T2>(Func<T, T2> mapper, Func<Exception, T2> error, Func<T2> cancel) { 350 public IPromise<T2> Then<T2>(Func<T, T2> mapper, Func<Exception, T2> error, Func<T2> cancel) {
351 var promise = new Promise<T2>(); 351 var promise = new Promise<T2>();
352 if (mapper != null)
353 promise.On(Cancel, PromiseEventType.Cancelled);
352 AddHandler(new RemapDescriptor<T2>(mapper, error, cancel, promise)); 354 AddHandler(new RemapDescriptor<T2>(mapper, error, cancel, promise));
353 return promise; 355 return promise;
354 } 356 }
355 357
356 public IPromise<T2> Then<T2>(Func<T, T2> mapper, Func<Exception, T2> error) { 358 public IPromise<T2> Then<T2>(Func<T, T2> mapper, Func<Exception, T2> error) {
357 var promise = new Promise<T2>(); 359 var promise = new Promise<T2>();
360 if (mapper != null)
361 promise.On(Cancel, PromiseEventType.Cancelled);
358 AddHandler(new RemapDescriptor<T2>(mapper, error, null, promise)); 362 AddHandler(new RemapDescriptor<T2>(mapper, error, null, promise));
359 return promise; 363 return promise;
360 } 364 }
361 365
362 public IPromise<T2> Then<T2>(Func<T, T2> mapper) { 366 public IPromise<T2> Then<T2>(Func<T, T2> mapper) {
363 var promise = new Promise<T2>(); 367 var promise = new Promise<T2>();
368 if (mapper != null)
369 promise.On(Cancel, PromiseEventType.Cancelled);
364 AddHandler(new RemapDescriptor<T2>(mapper, null, null, promise)); 370 AddHandler(new RemapDescriptor<T2>(mapper, null, null, promise));
365 return promise; 371 return promise;
366 } 372 }
367 373
368 public IPromise<T2> Chain<T2>(Func<T, IPromise<T2>> chained, Func<Exception, IPromise<T2>> error, Func<IPromise<T2>> cancel) { 374 public IPromise<T2> Chain<T2>(Func<T, IPromise<T2>> chained, Func<Exception, IPromise<T2>> error, Func<IPromise<T2>> cancel) {