我已经使用withLatestFrom来获取switchMap之前的状态下的商店值。
loadApps$ = this.actions$.pipe(
ofType(AppActionsTypes.LoadApps),
withLatestFrom(this.store.select(fromRoot.getCritera)),
switchMap(([action, request]) => this.service.getApps(request).pipe(
map((result) => new actions.LoadAppsSuccess(result))
))
switchMap([action,request])中的请求以Observable<Criteria>
的形式发出,而不仅仅是Criteria对象。我原本希望从中发射出普通物体,并且无法观察到。
getCriteria
的类型为MemoizedSelector<object, Criteria>
。它创建为
export const moduleState = CreateFeatureSelector<State>('apps');
export const appState = createSelector(moduleState, (state) => state.apps);
export const getCriteria = createSelector(appState, (state) => state.criteria);