我的效果很小,我需要获得动作数据( nanoId ),我需要使用这个nanoId来选择数据:
@Effect()
syncObj$ = this.actions$.pipe(
ofType(ObjActions.Actions.SYNC_NEW_OBJ),
mergeMap(({nanoId, obj}) => {
this.store.pipe(select(getObjByNanoId(nanoId), first())).subscribe(eObj => {
// return [] <-- error if I try to return pipe result here and remove return below
})
return [] // <-- this is below return
}
)
);我想到了withLatestFrom(),但正如我所理解的,它需要一个额外的管道。我的目标是从操作中捕获对象和nanoId,然后选择一个带有nanoId in store (eOnj)的对象,并比较它的一些字段。谢谢!
发布于 2020-10-18 05:18:47
注意,您不必在withLatestFrom中订阅,因为它需要一个可观察的。
@Effect()
syncObj$ = this.actions$.pipe(
ofType(ObjActions.Actions.SYNC_NEW_OBJ),
mergeMap(action => {
return of(action).pipe(
withLatestFrom(
this.store.pipe(select(getObjByNanoId(nanoId)),
)
)
}),
mergeMap(([action, obj]) => {
// code here
})
);https://stackoverflow.com/questions/64409388
复制相似问题