ngrx - 如何使用 withLatestFrom 运算符在 Effects 中获取存储状态
问题描述
我正在尝试这个
payloadToBeSaved$ = createEffect(() => this.actions$
.ofType(SOME_ACTION)
.withLatestFrom(this.store$)
.map(([action: Action, storeState: AppState]) => {
// Do something ...
});
但是 this.actions$ 是一个可观察的,我必须使用 this.actions$.pipe().... 当我尝试使用 pipe() 时,所有行都是红色的错误。不知道怎么修。
解决方案
@Effect()
shipOrder = this.actions.pipe(
ofType<ShipOrder>(ActionTypes.ShipOrder),
map(action => action.payload),
concatMap(action =>
of(action).pipe(
withLatestFrom(store.pipe(select(getUserName)))
)
),
map([payload, username] => {
...
})
)
推荐阅读
- python - 如何在反向 shell 中继续执行命令?
- awk - 如果条件匹配,则行中的所有标题名称
- spring-boot - 此应用程序没有 /error 的显式映射,因此您将其视为后备 404 Not found
- amazon-web-services - aws.config.update() 未更新 AWS 凭证
- r - 使用带有 rpy2 的 Python 调用 R 包数据
- android - 在 Android 上构建调试与发布
- php - 未找到列:1054 未知列 'attributevalues.products_id
- javascript - 仅当它具有值时才添加到 div 上的输入
- android - 在 Android 上获得一个空的重复通知(iOS 工作正常)
- javascript - 在 MERN 堆栈应用程序中每天限制一票