Skip to content

Commit

Permalink
docs(create-injection-token): add extraProviders use-case with ngrx
Browse files Browse the repository at this point in the history
  • Loading branch information
nartc committed Nov 5, 2023
1 parent 5c8c9a0 commit b17ae1d
Showing 1 changed file with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,31 @@ export const [injectCount, provideCount] = createInjectionToken(countFactory, {

We can also pass in other providers, via `extraProviders`, to `createInjectionToken` so when we call `provideFn()`, we provide those providers as well.

Example TBD
```ts
import { bookReducer } from './book.reducer';
import * as bookEffects from './book.effects';

export const [injectBookService, provideBookService] = createInjectionToken(
() => {
const store = inject(Store);
/* ... */
},
{
isRoot: false,
extraProviders: [provideState('book', bookReducer), provideEffects(bookEffects)],
}
);

// routes.ts
export const routes = [
{
path: 'book/:id',
// 👇 will also provideState() and provideEffects
providers: [provideBookService()],
loadComponent: () => import('./book/book.component'),
},
];
```

#### `multi`

Expand Down

0 comments on commit b17ae1d

Please sign in to comment.