我有一个带有 props 的选择器(类型为 MemoizedSelectorWithProps)。我想在 WithLatestFrom 内的效果中使用它。问题是 - 选择器的参数(道具)来自操作负载。我无法使 withLatestFrom 访问操作有效负载。
我正在使用 Angular 7(当然还有 ngrx7)。我尝试使用地图以某种方式创建一个新的可观察对象,但没有任何效果......
这些是我在这里写的一些演示行,以简化我的用例:
行动:
export const GET_INVENTORY = '[App] Get Inventory';
export class GetInventory implements Action {
readonly type = GET_INVENTORY;
constructor (public branchId: number) {}
}
Run Code Online (Sandbox Code Playgroud)
影响:
@Effect()
getInventory$ = this.actions$.pipe(
ofType(GET_INVENTORY)
withLatestFrom(this.store$.pipe(select(getIsStoreInventoryLoaded, {branchId: action.branchId}))), // this is not working obviously, since action is unknown
switchMap([action, loaded]: [GetInventory, boolean] => {
if (loaded) {
console.log('already loaded inventory for this branch', action.branchId);
} else {
console.log('never loaded inventory …Run Code Online (Sandbox Code Playgroud)