-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
`createEffect()` now returns not just a function, but a function with methods! :) API is experimental and might change, so it's documented only here for now. In your store: ```ts import { createEffect } from './create-effect'; class Store extends Collection<Item> { readonly changeZipCode = createEffect<string>(_ => _.pipe( // code to change zipcode )); } ``` In your component: ```ts class Component { store = inject(Store); dialog = inject(Dialog); changeZipCode(zipCode: string) { this.store.changeZipCode.nextValue(() => this.dialog.close()); this.store.changeZipCode(zipCode); } } ``` In this example, the dialog window will be closed only *after* the service response, and only if it was successful. Alongside nextValue, there are other methods: ```ts export type EffectFnMethods = { nextValue: (fn: ((v: unknown) => void)) => void, nextError: (fn: ((v: unknown) => void)) => void, onNextValue(): Observable<unknown>, onNextError(): Observable<unknown>, }; ``` Internally, values and errors will not be saved in memory if you don't use these methods.
- Loading branch information
Showing
2 changed files
with
86 additions
and
8 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