Skip to content

Commit

Permalink
refactor(core): remove private whenStable
Browse files Browse the repository at this point in the history
The `@angular/ssr` package no longer depends on this symbol.
  • Loading branch information
alan-agius4 committed Nov 26, 2024
1 parent fa2f895 commit 4ec9d64
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 33 deletions.
30 changes: 1 addition & 29 deletions packages/core/src/application/application_ref.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
setThrowInvalidWriteToSignalError,
} from '@angular/core/primitives/signals';
import {Observable, Subject, Subscription} from 'rxjs';
import {first, map} from 'rxjs/operators';
import {map} from 'rxjs/operators';

import {ZONELESS_ENABLED} from '../change_detection/scheduling/zoneless_scheduling';
import {Console} from '../console';
Expand Down Expand Up @@ -915,34 +915,6 @@ export const enum ApplicationRefDirtyFlags {
RootEffects = 0b00010000,
}

let whenStableStore: WeakMap<ApplicationRef, Promise<void>> | undefined;
/**
* Returns a Promise that resolves when the application becomes stable after this method is called
* the first time.
*
* Note: this function is unused in the FW code, but it's still present since the CLI code relies
* on it currently (see https://github.com/angular/angular-cli/blob/20411f696eb52c500e096e3dfc5e195185794edc/packages/angular/ssr/src/routes/ng-routes.ts#L435).
* Remove this function once CLI code is updated to use `ApplicationRef.whenStable` instead.
*/
export function whenStable(applicationRef: ApplicationRef): Promise<void> {
whenStableStore ??= new WeakMap();
const cachedWhenStable = whenStableStore.get(applicationRef);
if (cachedWhenStable) {
return cachedWhenStable;
}

const whenStablePromise = applicationRef.isStable
.pipe(first((isStable) => isStable))
.toPromise()
.then(() => void 0);
whenStableStore.set(applicationRef, whenStablePromise);

// Be a good citizen and clean the store `onDestroy` even though we are using `WeakMap`.
applicationRef.onDestroy(() => whenStableStore?.delete(applicationRef));

return whenStablePromise;
}

export function detectChangesInViewIfRequired(
lView: LView,
notifyErrorHandler: boolean,
Expand Down
5 changes: 1 addition & 4 deletions packages/core/src/core_private_export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@
*/

export {setAlternateWeakRefImpl as ɵsetAlternateWeakRefImpl} from '../primitives/signals';
export {
detectChangesInViewIfRequired as ɵdetectChangesInViewIfRequired,
whenStable as ɵwhenStable,
} from './application/application_ref';
export {detectChangesInViewIfRequired as ɵdetectChangesInViewIfRequired} from './application/application_ref';
export {INTERNAL_APPLICATION_ERROR_HANDLER as ɵINTERNAL_APPLICATION_ERROR_HANDLER} from './error_handler';
export {
IMAGE_CONFIG as ɵIMAGE_CONFIG,
Expand Down

0 comments on commit 4ec9d64

Please sign in to comment.