From 414599cee6dc6f7918d22b83c7444c17f4ab8692 Mon Sep 17 00:00:00 2001 From: Artur Androsovych Date: Mon, 18 Dec 2023 10:31:25 +0000 Subject: [PATCH] fix(store): ensure features are initialized after root state (#2083) We have a check that ensures states are initialized in the correct order and that the `UpdateState` action shouldn't be dispatched before the `InitState` action. This code updates the order of environment providers to place features at the end. As a result, the root environment initializer runs earlier, dispatching the `InitState` action. --- CHANGELOG.md | 3 ++- packages/store/src/standalone-features/provide-store.ts | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2d03b8f42..cd591d3c3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,8 @@ $ npm install @ngxs/store@dev ### To become next patch version -- Feat: schematics support a project option and standalone detection [#2089](https://github.com/ngxs/store/pull/2089) +- Feat: Schematics support a project option and standalone detection [#2089](https://github.com/ngxs/store/pull/2089) +- Fix: Ensure features are initialized after root state [#2083](https://github.com/ngxs/store/pull/2083) - Fix: Log feature states added before store is initialized [#2067](https://github.com/ngxs/store/pull/2067) - Fix: Show error when state initialization order is invalid [#2066](https://github.com/ngxs/store/pull/2066), [#2067](https://github.com/ngxs/store/pull/2067) - Fix: Router Plugin - Expose `NGXS_ROUTER_PLUGIN_OPTIONS` privately [#2037](https://github.com/ngxs/store/pull/2037) diff --git a/packages/store/src/standalone-features/provide-store.ts b/packages/store/src/standalone-features/provide-store.ts index 22a04e992..22c4864c3 100644 --- a/packages/store/src/standalone-features/provide-store.ts +++ b/packages/store/src/standalone-features/provide-store.ts @@ -52,8 +52,8 @@ export function provideStore( return makeEnvironmentProviders([ ...getRootProviders(states, options), - features, - NGXS_ROOT_ENVIRONMENT_INITIALIZER + NGXS_ROOT_ENVIRONMENT_INITIALIZER, + features ]); }