如果响应成功,我将尝试分派一个动作,如果响应失败,我将分派另一个动作。当我构造如下所示的效果时,我收到无效的操作错误。是否可以在效果内添加条件语句?
@Effect()
public makeFirstRequest = this.actions.pipe(
ofType<InitialAction>(ActionTypes.InitialAction),
switchMap(action => this.myService.firstRequest(action.param)),
map(response => {
if (success) {
new FollowUpAction(response))
}else {
new ErrorAction(response))
}
);
答案 0 :(得分:1)
您必须返回操作:
body