Skip to content

Instantly share code, notes, and snippets.

@arturovt
Last active October 14, 2019 08:55
Show Gist options
  • Save arturovt/058df145a87517161c9003b90fbac21a to your computer and use it in GitHub Desktop.
Save arturovt/058df145a87517161c9003b90fbac21a to your computer and use it in GitHub Desktop.
@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