【发布时间】:2019-09-14 08:41:34
【问题描述】:
我有这部史诗:
export const updateIsNotVeganInDbFulfilledEpic: Epic < * , * , * > = (
action$: ActionsObservable < * > ,
store: Store < * , * >
): Observable < any > =>
action$.ofType('UPDATE_IS_NOT_VEGAN_IN_DB_FULFILLED').mergeMap(action => {
return Observable.of(
updateToastComponentIsOpen(true),
updateToastComponentMessage(action.payload.response.errors[0])
)
})
如何在updateToastComponentIsOpen(true) 2 秒后调度另一个操作 (updateToastComponentIsOpen(false))?
我试过了:
action$.ofType('UPDATE_IS_NOT_VEGAN_IN_DB_FULFILLED').mergeMap(action => {
return Observable.of(
updateToastComponentIsOpen(true),
updateToastComponentMessage(action.payload.response.errors[0])
).timeout(2000)
.flatMap(function(result) {
return Observable.of(updateToastComponentIsOpen(false))
})
})
但它阻止了前两个动作的调度。
【问题讨论】:
标签: react-redux rxjs5 redux-observable