Skip to content

Commit fc2181e

Browse files
committed
fix(Dart1.8): Promise handling
1 parent 0703ee5 commit fc2181e

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

modules/di/src/injector.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,9 +203,10 @@ class _AsyncInjectorStrategy {
203203
var deps = this.injector._resolveDependencies(key, binding, true);
204204
var depsPromise = PromiseWrapper.all(deps);
205205

206-
var promise = PromiseWrapper.then(depsPromise, null, (e) => this._errorHandler(key, e)).
207-
then(deps => this._findOrCreate(key, binding, deps)).
208-
then(instance => this._cacheInstance(key, instance));
206+
var promise = PromiseWrapper
207+
.then(depsPromise, null, (e) => this._errorHandler(key, e))
208+
.then(deps => this._findOrCreate(key, binding, deps))
209+
.then(instance => this._cacheInstance(key, instance));
209210

210211
this.injector._setInstance(key, new _Waiting(promise));
211212
return promise;

modules/facade/src/async.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@ class PromiseWrapper {
1212
return new Future.error(obj);
1313
}
1414

15-
static Future all(List<Future> promises){
15+
static Future<List> all(List<Future> promises){
1616
return Future.wait(promises);
1717
}
1818

1919
static Future then(Future promise, Function success, Function onError){
20+
if (success == null) return promise.catchError(onError);
2021
return promise.then(success, onError: onError);
2122
}
2223
}

0 commit comments

Comments
 (0)