【发布时间】:2018-08-15 20:46:31
【问题描述】:
我意识到了
const pingEpic = action$ =>
action$.ofType('PING')
.delay(1000) // Asynchronously wait 1000ms then continue
.mapTo({ type: 'PONG' });
意思
dispatch({ type: 'PING' });
dispatch({ type: 'PONG' });
Howeber,我不知道如何用管道调度两个动作。
我的代码在下面
const signUpEpic = (action$: Observable<Action>) => action$.pipe(
ofType(actions.GET_DEVICE_TOKEN),
ofType(actions.SIGN_UP),
exhaustMap(({ payload }) => request({
url: 'users',
method: 'post',
data: {
user: {
email: payload.email,
password: payload.password,
device_token: payload.device_token,
sign_up_with: 'email_and_password',
},
},
}).pipe(
map(data => camelcaseKeysDeep(data)),
map(({ user, authToken }) => currentUserActions.successLogin({ user, authToken })),
catchError((errorMessage: string) => Observable.of(actions.failLogin({ errorMessage }))),
)),
);
你有什么想法吗?
我也试过下面的代码。
ofType(actions.GET_DEVICE_TOKEN),
mapTo(actions.SIGN_UP),
谢谢
【问题讨论】:
-
抱歉,不清楚您在问什么。也许您可以将您提供的代码简化为只提供基本内容并详细说明问题?
标签: redux observable redux-observable