我在我的 React 项目中使用 react-observable 和 reselect。我想要实现的是这样的:
// 选择器
export const getItem = createSelector(getItemsState, state => state.item);
现在在 Epics 中,我想做这样的事情:
const addItem$: Epic = (action$: Observable<Actions>, state$) =>
action$.pipe(
filter(action => action.type === 'ADD_ITEM'),
withLatestFrom(state$.select(getItem)), // Just use there my selector which is written.
switchMap((item) => {
return ItemsApi.addItem(item);
},
),
);
有可能吗?谢谢你的帮助!