动作创作者

在 Redux 中处理异步的另一种方法是使用动作创建器。在 Flux 中,动作创建者是构造动作对象并派遣它们的特殊函数。

myActionCreator(dispatch) {
  dispatch({ type: "ASYNC_ACTION_START" });
  setTimeout(() => {
    dispatch({ type: "ASYNC_ACTION_END" });
  }, 1000)
}