MCPcopy
hub / github.com/angular/angular / wrapIntoObservable

Function wrapIntoObservable

packages/router/src/utils/collection.ts:73–86  ·  view source on GitHub ↗
(value: T | Promise<T> | Observable<T>)

Source from the content-addressed store, hash-verified

71}
72
73export function wrapIntoObservable<T>(value: T | Promise<T> | Observable<T>): Observable<T> {
74 if (isObservable(value)) {
75 return value;
76 }
77
78 if (isPromise(value)) {
79 // Use `Promise.resolve()` to wrap promise-like instances.
80 // Required ie when a Resolver returns a AngularJS `$q` promise to correctly trigger the
81 // change detection.
82 return from(Promise.resolve(value));
83 }
84
85 return of(value);
86}
87
88export function wrapIntoPromise<T>(value: T | Promise<T> | Observable<T>): Promise<T> {
89 if (isObservable(value)) {

Callers 8

runSeriallyFunction · 0.90
getRedirectResultFunction · 0.90
runCanActivateFunction · 0.90
runCanActivateChildFunction · 0.90
runCanDeactivateFunction · 0.90
runCanLoadGuardsFunction · 0.90
runCanMatchGuardsFunction · 0.90
getResolverFunction · 0.90

Calls 2

isPromiseFunction · 0.85
resolveMethod · 0.65

Tested by 1

runSeriallyFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…