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