MCPcopy Create free account
hub / github.com/angular/angular / whenStableWithTimeout

Function whenStableWithTimeout

packages/core/src/hydration/api.ts:147–165  ·  view source on GitHub ↗

* Returns a Promise that is resolved when an application becomes stable.

(appRef: ApplicationRef)

Source from the content-addressed store, hash-verified

145 * Returns a Promise that is resolved when an application becomes stable.
146 */
147function whenStableWithTimeout(appRef: ApplicationRef): Promise<void> {
148 const whenStablePromise = appRef.whenStable();
149 if (typeof ngDevMode !== 'undefined' && ngDevMode) {
150 const timeoutTime = APPLICATION_IS_STABLE_TIMEOUT;
151 const console = appRef.injector.get(Console);
152 const ngZone = appRef.injector.get(NgZone);
153
154 // The following call should not and does not prevent the app to become stable
155 // We cannot use RxJS timer here because the app would remain unstable.
156 // This also avoids an extra change detection cycle.
157 const timeoutId = ngZone.runOutsideAngular(() => {
158 return setTimeout(() => logWarningOnStableTimedout(timeoutTime, console), timeoutTime);
159 });
160
161 whenStablePromise.finally(() => clearTimeout(timeoutId));
162 }
163
164 return whenStablePromise;
165}
166
167/**
168 * Defines a name of an attribute that is added to the <body> tag

Callers 1

withDomHydrationFunction · 0.85

Calls 7

setTimeoutFunction · 0.85
clearTimeoutFunction · 0.85
finallyMethod · 0.80
whenStableMethod · 0.65
getMethod · 0.65
runOutsideAngularMethod · 0.45

Tested by

no test coverage detected