use Promise instead of Future
This commit is contained in:
@ -3,20 +3,20 @@ library angular.core.facade.async;
|
||||
import 'dart:async';
|
||||
export 'dart:async' show Future;
|
||||
|
||||
class FutureWrapper {
|
||||
static Future value(obj) {
|
||||
class PromiseWrapper {
|
||||
static Future resolve(obj) {
|
||||
return new Future.value(obj);
|
||||
}
|
||||
|
||||
static Future error(obj) {
|
||||
static Future reject(obj) {
|
||||
return new Future.error(obj);
|
||||
}
|
||||
|
||||
static Future wait(List<Future> futures){
|
||||
return Future.wait(futures);
|
||||
static Future all(List<Future> promises){
|
||||
return Future.wait(promises);
|
||||
}
|
||||
|
||||
static Future catchError(Future future, Function onError){
|
||||
return future.catchError(onError);
|
||||
static Future then(Future promise, Function success, Function onError){
|
||||
return promise.then(success, onError: onError);
|
||||
}
|
||||
}
|
||||
|
@ -1,20 +1,20 @@
|
||||
export var Future = Promise;
|
||||
export var Promise = window.Promise;
|
||||
|
||||
export class FutureWrapper {
|
||||
static value(obj):Future {
|
||||
return Future.resolve(obj);
|
||||
export class PromiseWrapper {
|
||||
static resolve(obj):Promise {
|
||||
return Promise.resolve(obj);
|
||||
}
|
||||
|
||||
static error(obj):Future {
|
||||
return Future.reject(obj);
|
||||
static reject(obj):Promise {
|
||||
return Promise.reject(obj);
|
||||
}
|
||||
|
||||
static wait(futures):Future {
|
||||
if (futures.length == 0) return Future.resolve([]);
|
||||
return Future.all(futures);
|
||||
static all(promises):Promise {
|
||||
if (promises.length == 0) return Promise.resolve([]);
|
||||
return Promise.all(promises);
|
||||
}
|
||||
|
||||
static catchError(future:Future, onError:Function):Future {
|
||||
return future.catch(onError);
|
||||
static then(promise:Promise, success:Function, rejection:Function):Promise {
|
||||
return promise.then(success, rejection);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user