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 juleskremer committed Aug 24, 2017
1 parent 5b55619 commit 7c52958
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/router/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 7c52958

Please sign in to comment.