From fc2181ec4e45fb50a2a0aa12af50eb18af617506 Mon Sep 17 00:00:00 2001 From: Victor Berchet Date: Mon, 1 Dec 2014 20:06:21 +0100 Subject: [PATCH] fix(Dart1.8): Promise handling --- modules/di/src/injector.js | 7 ++++--- modules/facade/src/async.dart | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/modules/di/src/injector.js b/modules/di/src/injector.js index 7b445c9ba8..e7644658e8 100644 --- a/modules/di/src/injector.js +++ b/modules/di/src/injector.js @@ -203,9 +203,10 @@ class _AsyncInjectorStrategy { var deps = this.injector._resolveDependencies(key, binding, true); var depsPromise = PromiseWrapper.all(deps); - var promise = PromiseWrapper.then(depsPromise, null, (e) => this._errorHandler(key, e)). - then(deps => this._findOrCreate(key, binding, deps)). - then(instance => this._cacheInstance(key, instance)); + var promise = PromiseWrapper + .then(depsPromise, null, (e) => this._errorHandler(key, e)) + .then(deps => this._findOrCreate(key, binding, deps)) + .then(instance => this._cacheInstance(key, instance)); this.injector._setInstance(key, new _Waiting(promise)); return promise; diff --git a/modules/facade/src/async.dart b/modules/facade/src/async.dart index 42fc7f428f..2e1e6ae746 100644 --- a/modules/facade/src/async.dart +++ b/modules/facade/src/async.dart @@ -12,11 +12,12 @@ class PromiseWrapper { return new Future.error(obj); } - static Future all(List promises){ + static Future all(List promises){ return Future.wait(promises); } static Future then(Future promise, Function success, Function onError){ + if (success == null) return promise.catchError(onError); return promise.then(success, onError: onError); } }