Last active
October 14, 2019 08:55
-
-
Save arturovt/058df145a87517161c9003b90fbac21a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
@Injectable() | |
export class TodosEffects { | |
@Effect() | |
public setTodos$ = this.actions$.pipe( | |
ofType(Actions.GET_TODOS), | |
exhaustMap(() => someService.getTodos()), | |
map((todos) => ({ | |
type: Actions.SET_TODOS, | |
payload: todos | |
})) | |
); | |
constructor(private actions$: Actions) {} | |
} | |
// Псевдокод | |
todosEffectsInstance.setTodos$.subscribe(({ type, payload }) => { | |
store.dispatch({ type, payload }); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment