【发布时间】:2017-05-04 01:07:19
【问题描述】:
我正在使用 redux-observable,这就是我想要做的。
-
当 'APPLY_SHOPPING_LIST' 的 actiontype 进入调度 'APPLYING_SHOPPING_LIST' 并在 5 秒后调度 'APPLIED_SHOPPING_LIST'。这是我目前想出的代码
const applyingShoppingListSource = action$.ofType('APPLY_SHOPPING_LISTS').mapTo({ type: 'APPLYING_SHOPPING_LISTS' }); const applyingShoppingListSourceOther = action$.ofType('APPLY_SHOPPING_LISTS').mapTo({ type: 'APPLIED_SHOPPING_LISTS' }).delay(5000); const concatList = applyingShoppingListSource.concat(applyingShoppingListSourceOther);返回连接列表;
现在的问题是只有 'APPLYING_SHOPPING_LISTS' 被触发,'APPLIED_SHOPPING_LISTS' 根本没有被触发到减速器。我在这里遗漏了什么吗?
补充一点,当我使用 flatMap 时,它可以工作,下面给出的是代码
return action$.ofType('APPLY_SHOPPING_LISTS')
.flatMap(() => Observable.concat(Observable.of({ type: 'APPLYING_SHOPPING_LISTS' }), Observable.of({ type: 'APPLYING_SHOPPING_LISTS' });
我很困惑这是如何工作的,而另一个则不是?
【问题讨论】:
标签: redux-observable