Skip to content

Instantly share code, notes, and snippets.

@arturovt
Last active March 14, 2019 10:47
Show Gist options
  • Save arturovt/e4d49b4fcddfcba27ed950b63f635657 to your computer and use it in GitHub Desktop.
Save arturovt/e4d49b4fcddfcba27ed950b63f635657 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) {}
}
// В рантайме после вызова декораторов
class TodosEffects {
public static '__@ngrx/effects__' = [
{
propertyName: 'setTodos$',
dispatch: true
}
];
public setTodos$ = ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment