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

Function whenStableWithTimeout

packages/core/src/hydration/api.ts:146–164  ·  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

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