Effect
初始化时需要定义好effects,是一个函数集合
import storact from 'storact'
const {
useDispatch,
useStoreState,
Provider,
} = storact({
initialState,
middlewares,
effects, // effect集合 - optional
namespace,
})
export { useDispatch, useStoreState, Provider }具体一个effect的格式如下
({ getState, dispatch }) => async () => {}
// getState同useStoreState(参考 "使用/创建store")
// dispatch不仅可以调用基础的action,还可以调用其他effect具体使用
例如当前状态如下
定义一个effect
再定义一个effect
Last updated
Was this helpful?