Skip to content

Commit

Permalink
fix(router): Wrap Promise-like instances in native Promises (angular#…
Browse files Browse the repository at this point in the history
…16759)

Hybrid apps (mix of Angular and AngularJS) might return AngularJS implementation
of Promises that do not play well with the change detection. Wrapping them in
native Promises fix this issue.

This could be the case when a Resolver returns a `$q` promise.
  • Loading branch information
vicb authored and jasonaden committed May 12, 2017
1 parent 2130763 commit b87bff6
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/utils/collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,10 @@ export function wrapIntoObservable<T>(value: T | NgModuleFactory<T>| Promise<T>|
}

if (isPromise(value)) {
return fromPromise(value);
// Use `Promise.resolve()` to wrap promise-like instances.
// Required ie when a Resolver returns a AngularJS `$q` promise to correctly trigger the
// change detection.
return fromPromise(Promise.resolve(value));
}

return of (value);
Expand Down

0 comments on commit b87bff6

Please sign in to comment.