Skip to content

Commit

Permalink
feat: withDevTools disabled in prod, and tree-shaking docs - docs uti…
Browse files Browse the repository at this point in the history
…lity function update
  • Loading branch information
marcindz88 authored and rainerhahnekamp committed Oct 18, 2024
1 parent 4c2baa9 commit ada5f26
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@ updateState(this.store, 'update loading', { loading: false });

<summary>Devtools tree-shaking details</summary>

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';

Expand All @@ -103,7 +105,7 @@ export const environment = {
}
```

environment.prod.ts
environments/environment.prod.ts
```typescript
import { withDevtoolsStub } from '@angular-architects/ngrx-toolkit';

Expand All @@ -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')
);
```

Expand Down

0 comments on commit ada5f26

Please sign in to comment.