From ada5f26eda33ea63d46875ff1b4ad88d4e583278 Mon Sep 17 00:00:00 2001 From: marcindz88 Date: Fri, 18 Oct 2024 18:47:58 +0200 Subject: [PATCH] feat: withDevTools disabled in prod, and tree-shaking docs - docs utility function update --- README.md | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 1f86600..53048bf 100644 --- a/README.md +++ b/README.md @@ -94,7 +94,9 @@ updateState(this.store, 'update loading', { loading: false }); Devtools tree-shaking details - environment.ts: +It is required to add the `withDevtools` function to the environment files. + +environments/environment.ts: ```typescript import { withDevtools } from '@angular-architects/ngrx-toolkit'; @@ -103,7 +105,7 @@ export const environment = { } ``` -environment.prod.ts +environments/environment.prod.ts ```typescript import { withDevtoolsStub } from '@angular-architects/ngrx-toolkit'; @@ -112,12 +114,21 @@ export const environment = { } ``` -Then all you need to do is replace `withDevTools` everywhere in your app with `environment.storeWithDevTools` +Then you can create utility function which can be used across the application e.g.: + +shared/store.features.ts (or any other file) +```typescript +import { environment } from 'src/environments/environment'; + +export const withTreeShakableDevTools = environment.storeWithDevTools; +``` + +And use it in your store definitions: ```typescript export const SomeStore = signalStore( withState({strings: [] as string[] }), - environment.storeWithDevTools('featureName') + withTreeShakableDevTools('featureName') ); ```