-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(store): add possibility to dispatch Signal<Action>
A type of Signal<Action> can be passed to dispatch: ```typescript class BookComponent { bookId = input.required<number>(); bookAction = computed(() => loadBook({id: this.bookId()})); store = inject(Store); constructor() { this.store.dispatch(this.bookAction); } } ``` The benefit is that users no longer need to use an effect to track the Signal. The Store handles this internally. If `dispatch` receives a `Signal` it returns an `EffectRef`, allowing manual destruction. By default, the injection context of the caller is used. If the call happens outside an injection context, the Store will use its own injection context, which is usually the root injector. It is also possible to provide a custom injector as the second parameter: ```typescript this.store.dispatch(this.bookAction, {injector: this.injector}); ```
- Loading branch information
1 parent
ab1d1b4
commit f70110f
Showing
5 changed files
with
226 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters