From 2db2791baeaa4cc20dd4790ea35aae8a2e2f2790 Mon Sep 17 00:00:00 2001 From: Sheik Althaf Date: Sun, 13 Oct 2024 09:41:41 +0530 Subject: [PATCH] docs: update @ngrx/store-devtools examples to standalone --- .../content/guide/store-devtools/config.md | 10 ++--- .../content/guide/store-devtools/index.md | 27 +------------ .../content/guide/store-devtools/install.md | 3 +- .../guide/store-devtools/recipes/exclude.md | 38 +------------------ 4 files changed, 7 insertions(+), 71 deletions(-) diff --git a/projects/ngrx.io/content/guide/store-devtools/config.md b/projects/ngrx.io/content/guide/store-devtools/config.md index 627043740b..4b892376d2 100644 --- a/projects/ngrx.io/content/guide/store-devtools/config.md +++ b/projects/ngrx.io/content/guide/store-devtools/config.md @@ -75,12 +75,10 @@ features: { ## Example Object as provided in module imports - -@NgModule({ - ... - imports: [ - ... - StoreDevtoolsModule.instrument({ + +bootstrapApplication(AppComponent, { + providers: [ + provideStoreDevtools({ maxAge: 25, logOnly: false, autoPause: true, diff --git a/projects/ngrx.io/content/guide/store-devtools/index.md b/projects/ngrx.io/content/guide/store-devtools/index.md index 5173b6f857..fc9c9e2fe8 100644 --- a/projects/ngrx.io/content/guide/store-devtools/index.md +++ b/projects/ngrx.io/content/guide/store-devtools/index.md @@ -12,32 +12,7 @@ Instrumentation with the Chrome / Firefox Extension 1. Download the [Redux Devtools Extension](https://github.com/reduxjs/redux-devtools/) -2. In your `AppModule` add instrumentation to the module imports using `StoreDevtoolsModule.instrument`: - - -import { NgModule, isDevMode } from '@angular/core'; -import { StoreDevtoolsModule } from '@ngrx/store-devtools'; - -@NgModule({ - imports: [ - StoreModule.forRoot(reducers), - // Instrumentation must be imported after importing StoreModule (config is optional) - StoreDevtoolsModule.instrument({ - maxAge: 25, // Retains last 25 states - logOnly: !isDevMode(), // Restrict extension to log-only mode - autoPause: true, // Pauses recording actions and state changes when the extension window is not open - trace: false, // If set to true, will include stack trace for every dispatched action, so you can see it in trace tab jumping directly to that part of code - traceLimit: 75, // maximum stack trace frames to be stored (in case trace option was provided as true) - connectInZone: true // If set to true, the connection is established within the Angular zone - }), - ], -}) -export class AppModule {} - - -### Using the Standalone API - -Registering the instrumentation can also be done using the standalone APIs if you are bootstrapping an Angular application using standalone features. +2. Provide the `provideStoreDevtools` in your bootstrapApplication: import { isDevMode } from '@angular/core'; diff --git a/projects/ngrx.io/content/guide/store-devtools/install.md b/projects/ngrx.io/content/guide/store-devtools/install.md index c541c56720..32bf3aaabf 100644 --- a/projects/ngrx.io/content/guide/store-devtools/install.md +++ b/projects/ngrx.io/content/guide/store-devtools/install.md @@ -21,8 +21,7 @@ This command will automate the following steps: 1. Update `package.json` > `dependencies` with `@ngrx/store-devtools`. 2. Run `npm install` to install those dependencies. -3. Update your `src/app.module.ts` > `imports` array with `StoreDevtoolsModule.instrument({ maxAge: 25, logOnly: !isDevMode() })`. The maxAge property will be set to the flag `maxAge` if provided. -4. If the project is using a `standalone bootstrap`, it adds `provideStoreDevtools({ maxAge: 25, logOnly: !isDevMode() })` into the application config. +3. Update your project is using a `standalone bootstrap`, it adds `provideStoreDevtools({ maxAge: 25, logOnly: !isDevMode() })` into the application config. ## Installing with `npm` diff --git a/projects/ngrx.io/content/guide/store-devtools/recipes/exclude.md b/projects/ngrx.io/content/guide/store-devtools/recipes/exclude.md index 79615b583b..4437e3df28 100644 --- a/projects/ngrx.io/content/guide/store-devtools/recipes/exclude.md +++ b/projects/ngrx.io/content/guide/store-devtools/recipes/exclude.md @@ -12,19 +12,6 @@ If the environment files don't exist in your project you can use the `ng generat Given the below example: - -import { StoreDevtoolsModule } from '@ngrx/store-devtools'; - -export const environment = { - production: false, - imports: [ - StoreDevtoolsModule.instrument({ maxAge: 25 }) - ], -}; - - -When using the standalone API, use the `providers` array instead of `imports`: - import { provideStoreDevtools } from '@ngrx/store-devtools'; @@ -36,32 +23,9 @@ export const environment = { }; -Now, let's add an empty `imports` property to the production environment file: - - -export const environment = { - production: true, - imports: [], -}; - - ## Step 2: Import Environment File -Modify `app.module.ts` to include `environment.imports` in the `imports` array. - - -import { environment } from '../environments/environment'; - -@NgModule({ - imports: [ - StoreModule.forRoot(reducers), - // Instrumentation must be imported after importing StoreModule - environment.imports, - ], -}) - - -When using the standalone API, modify the `app.config.ts` file, where your application configuration resides, to specify `environment.providers`: +Modify the `app.config.ts` file, where your application configuration resides, to specify `environment.providers`: import { environment } from '../environments/environment';