问题似乎出在你自己身上
of(takeAction(res, reply))
.pipe(...)
. 把你的“采取行动”命令发给那些东西
里面
这个
.pipe
action$.pipe(
ofType(START_FOO),
switchMap({ url } =>
from(fetch(url)).pipe(
mergeMap(res => from(res.text()).pipe(
mergeMap(reply => {
try {
reply = JSON.parse(reply)
} catch (ignore) {
}
switch (res.status) {
case 200: {
return merge(
of(takeAction(res, reply)),
action$.pipe(
ofType(RESOLVE_TAKE, REJECT_TAKE),
map(({ type }) => {
if (type === RESOLVE_TAKE) {
return resolveFooAction()
} else {
return rejectFooAction()
}
}),
),
)
}
// other res.status cases go here
}
})
)
)
)
)
在上面的例子中
采取行动
不
用管道输送到任何地方。相反,它被“流”回Redux商店。这个
merge
是一种在创建对动作流的另一个订阅以临时侦听另一个事件的同时将某些内容流出来的方法。