reactjs – 你怎么认为flowtype redux thunk?
发布时间:2020-12-15 20:12:58 所属栏目:百科 来源:网络整理
导读:我目前正在做的是: export type Action = { type: 'FOO' } | { type: 'BAR' }export type Thunk = (dispatch: Dispatch,getState: GetState) = Action | Thunk export type Dispatch = ReduxDispatchAction (action: Thunk) = void 但如果您直接在商店发货,
我目前正在做的是:
export type Action = { type: 'FOO' } | { type: 'BAR' } export type Thunk = (dispatch: Dispatch,getState: GetState) => Action | Thunk export type Dispatch = ReduxDispatch<Action> & (action: Thunk) => void 但如果您直接在商店发货,那么在没有重新创建商店的情况下将无效: export type Store = ReduxStore< State,Action> 一般来说,我的thunk解决方案似乎还有其他一些小问题.有没有人有redux-thunk的工作库定义?我找不到任何地方. 解决方法
我到目前为止找到的最好的例子是Facebook自己的F8应用程序
here中使用的例子.
它与你的非常相似: export type Dispatch = (action: Action | ThunkAction | PromiseAction | Array<Action>) => any; export type GetState = () => Object; export type ThunkAction = (dispatch: Dispatch,getState: GetState) => any; export type PromiseAction = Promise<Action>; 到目前为止,在我的项目中它对我来说效果很好,尽管我不会在任何地方直接在商店发送. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容