GetUser操作
export const getUser = ()=>({
type:T.GET_USER,
});
LoginUser史诗
export const getUser = (action$: any) => action$.pipe(
ofType(T.GET_USER),
mergeMap(({payload}) =>
getAjax('/auth/user', 'GET').pipe(
map(({response}) => A.getUserFulfilled(response))
)
)
);
我有像上面那样的动作和史诗。当我像下面那样触发动作时,我想获得Loginuser史诗结果作为如下所示的动作的返回值
// Start dispatch
const resp = dispatch(getUser())
// GET RESULTS HERE (USER variable from ajax request)
console.log(resp)
如何使用redux-observable做到这一点?