你怎么认为flowtype redux thunk?

fac*_*com 7 reactjs redux redux-thunk react-redux

我目前正在做的是:

export type Action =
   { type: 'FOO' }
 | { type: 'BAR' }

export type Thunk = (dispatch: Dispatch, getState: GetState) => Action | Thunk 

export type Dispatch = ReduxDispatch<Action> & (action: Thunk) => void
Run Code Online (Sandbox Code Playgroud)

但如果你直接派遣store,那将无法重新创建store:

export type Store = ReduxStore<State, Action>

一般来说,我的thunk解决方案似乎还有其他一些小问题.有没有人有工作库定义redux-thunk?我找不到任何地方.

小智 8

到目前为止,我已经找到了最好的例子是在Facebook的F8自己的应用程序所使用的那些在这里.

它与你的非常相似:

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>;
Run Code Online (Sandbox Code Playgroud)

到目前为止,在我的项目中它对我来说效果很好,尽管我不会在任何地方直接在商店发送.