【发布时间】:2021-06-25 09:59:36
【问题描述】:
我有这样的事情
ngOnInit() {
this.store.dispatch(new TutorialActions.GetTutorials(1, 20));
}
export class GetTutorials implements Action {
readonly type = GET_TUTORIALS
constructor(public number: number, public offset: number) {}
}
然后我有这样的效果
export class TutorialEffects {
loadTutorials$ = createEffect(() =>
this.action$.pipe(
ofType(TutorialActions.GET_TUTORIALS),
switchMap(() =>
this.tutorialService.getAll(0, 20).pipe(
map((tutorial: Tutorial[]) => new TutorialActions.SuccesGetTutorials(tutorial)),
catchError((error) => of (error))
)
)
)
);
}
问题出在ofType(TutorialActions.GET_TUTORIALS)、this.tutorialService.getAll(0,20)。
该值应该从ngOnInit 函数传递并且可以是动态的?
【问题讨论】:
标签: angular rxjs observable ngrx