From 25615db40238f66893279af04c16e5b3ed1204fd Mon Sep 17 00:00:00 2001 From: arturovt Date: Fri, 29 Nov 2024 00:19:56 +0200 Subject: [PATCH] refactor: address feedback --- packages/store/experimental/src/index.ts | 14 +++++++++++++- packages/store/src/pending-tasks.ts | 4 +++- .../__snapshots__/preboot-wait-stable.spec.ts.snap | 0 .../tests/preboot-wait-stable.spec.ts | 6 +++--- 4 files changed, 19 insertions(+), 5 deletions(-) rename packages/store/{experimental => }/tests/__snapshots__/preboot-wait-stable.spec.ts.snap (100%) rename packages/store/{experimental => }/tests/preboot-wait-stable.spec.ts (92%) diff --git a/packages/store/experimental/src/index.ts b/packages/store/experimental/src/index.ts index 35959551d..cb7a7dd63 100644 --- a/packages/store/experimental/src/index.ts +++ b/packages/store/experimental/src/index.ts @@ -1 +1,13 @@ -export { withExperimentalNgxsPendingTasks } from './pending-tasks'; +import { withNgxsPendingTasks } from '@ngxs/store'; + +/** + * Required for correct functioning of SSR apps. + * + * @deprecated + * This experimental export is deprecated in favour of the non-experimental export. + * This is no longer an experimental feature, but is now available as + * `withNgxsPendingTasks` in the main `@ngxs/store` package. + */ +export function withExperimentalNgxsPendingTasks() { + return withNgxsPendingTasks(); +} diff --git a/packages/store/src/pending-tasks.ts b/packages/store/src/pending-tasks.ts index 9528dfb43..f9e6c320d 100644 --- a/packages/store/src/pending-tasks.ts +++ b/packages/store/src/pending-tasks.ts @@ -4,10 +4,12 @@ import { Actions, ActionStatus } from './actions-stream'; import { withNgxsPreboot } from './standalone-features/preboot'; /** - * This feature that contributes to app stability, * which is required during + * This feature that contributes to app stability, which is required during * server-side rendering. With asynchronous actions being dispatched and handled, * Angular is unaware of them in zoneless mode and doesn't know whether the app is * still unstable. This may prematurely serialize the final HTML that is sent to the client. + * Including `withNgxsPendingTasks` in your `provideStore` for your SSR + * app will resolve the above issue. */ export function withNgxsPendingTasks() { return withNgxsPreboot(() => { diff --git a/packages/store/experimental/tests/__snapshots__/preboot-wait-stable.spec.ts.snap b/packages/store/tests/__snapshots__/preboot-wait-stable.spec.ts.snap similarity index 100% rename from packages/store/experimental/tests/__snapshots__/preboot-wait-stable.spec.ts.snap rename to packages/store/tests/__snapshots__/preboot-wait-stable.spec.ts.snap diff --git a/packages/store/experimental/tests/preboot-wait-stable.spec.ts b/packages/store/tests/preboot-wait-stable.spec.ts similarity index 92% rename from packages/store/experimental/tests/preboot-wait-stable.spec.ts rename to packages/store/tests/preboot-wait-stable.spec.ts index fa44bcc49..14d1f499e 100644 --- a/packages/store/experimental/tests/preboot-wait-stable.spec.ts +++ b/packages/store/tests/preboot-wait-stable.spec.ts @@ -15,10 +15,10 @@ import { StateToken, dispatch, provideStore, - select + select, + withNgxsPendingTasks } from '@ngxs/store'; import { freshPlatform, skipConsoleLogging } from '@ngxs/store/internals/testing'; -import { withExperimentalNgxsPendingTasks } from '@ngxs/store/experimental'; describe('preboot feature + stable', () => { const COUNTRIES_STATE_TOKEN = new StateToken('countries'); @@ -69,7 +69,7 @@ describe('preboot feature + stable', () => { providers: [ provideExperimentalZonelessChangeDetection(), - provideStore([CountriesState], withExperimentalNgxsPendingTasks()) + provideStore([CountriesState], withNgxsPendingTasks()) ] }), {