When a React component dispatches actions, how can another service catch the actions, accumulate and group them, then redispatch a single action?
Catching actions to accumulate and group them
When a React component dispatches actions, how can another service catch the actions, accumulate and group them, then redispatch a single action?
Catching actions to accumulate and group them
这样可以方便的进行单元测试,不需要模拟Api.fetch函数的具体返回结果。
非模拟时,由redux-saga内部的调度器帮我们执行 next(在异步函数或副作用函数执行获得结果后);
模拟时,由测试函数自己根据需要执行 next,所以说无需模拟 Api.fetch 函数的具体返回结果,从而为测试带来了方便