【发布时间】:2017-07-22 20:45:07
【问题描述】:
我的应用使用了 ngrx 和 ngrx 效果。这是我的应用效果之一:
@Effect()
reloadPersonalInfo$: Observable<Action> = this.actions$
.ofType(currentUserAccount.ActionTypes.RELOAD_PERSONAL_INFO)
.filter(() => <boolean>JSON.parse(localStorage.getItem('authenticated')))
.switchMap(() =>
this.userAccountService
.retrieveCurrentUserAccount()
.map(currentUserAccount => new LoadUserAccountAction(currentUserAccount))
.map(() => new SigninAction())
);
我想知道为什么 LoadUserAccountAction 不进入我的减速器函数,除非我注释掉 //.map(() => new SigninAction())
有人可以帮忙吗?我做错了什么?
【问题讨论】:
-
效果只返回一个动作。
-
@Jim:感谢您的评论和编辑。您能否建议一种方法来更改应用程序的设计,以避免从效果中返回多个操作?
-
您正试图同时返回“LoadUserAccountAction”和“SigninAction”。您应该退回其中之一。换句话说,删除代码中的 .map 行之一。
-
我指的是carant的回复。你对只返回一个动作的评论是否也适用于返回几个与
concatMap“连接”的动作(见下面的回复)?
标签: rxjs rxjs5 ngrx ngrx-effects