Skip to content

Commit

Permalink
docs(nx): show how to configure an effect not to dispatch an action
Browse files Browse the repository at this point in the history
  • Loading branch information
vsavkin committed Nov 17, 2017
1 parent 194e9b3 commit 846d5e4
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion packages/nx/src/data-persistence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,16 @@ export class DataPersistence<T> {
* constructor(private s: DataPersistence<TodosState>, private backend: Backend) {}
* }
* ```
*
* Note that if you don't return a new action from the run callback, you must set the dispatch property
* of the effect to false, like this:
*
* ```
* class TodoEffects {
* @Effect({dispatch: false})
* updateTodo; //...
* }
* ```
*/
pessimisticUpdate<A extends Action = Action>(actionType: string, opts: PessimisticUpdateOpts<T, A>): Observable<any> {
const nav = this.actions.ofType<A>(actionType);
Expand Down Expand Up @@ -123,6 +133,16 @@ export class DataPersistence<T> {
* constructor(private s: DataPersistence<TodosState>, private backend: Backend) {}
* }
* ```
*
* Note that if you don't return a new action from the run callback, you must set the dispatch property
* of the effect to false, like this:
*
* ```
* class TodoEffects {
* @Effect({dispatch: false})
* updateTodo; //...
* }
* ```
*/
optimisticUpdate<A extends Action = Action>(actionType: string, opts: OptimisticUpdateOpts<T, A>): Observable<any> {
const nav = this.actions.ofType<A>(actionType);
Expand Down Expand Up @@ -243,7 +263,6 @@ export class DataPersistence<T> {
* constructor(private s: DataPersistence<TodosState>, private backend: Backend) {}
* }
* ```
*
*/
navigation(component: Type<any>, opts: HandleNavigationOpts<T>): Observable<any> {
const nav = this.actions
Expand Down

0 comments on commit 846d5e4

Please sign in to comment.