你应该如何使用 flowtype redux thunk?
How are you supposed to flowtype redux thunk?
我目前正在做的是:
export type Action =
{ type: 'FOO' }
| { type: 'BAR' }
export type Thunk = (dispatch: Dispatch, getState: GetState) => Action | Thunk
export type Dispatch = ReduxDispatch<Action> & (action: Thunk) => void
但如果您直接在 store
上发送,则不重新创建 store
将无法工作:
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>;
到目前为止,它在我的项目中对我来说效果很好,尽管我不会直接在任何地方的商店发货。
我目前正在做的是:
export type Action =
{ type: 'FOO' }
| { type: 'BAR' }
export type Thunk = (dispatch: Dispatch, getState: GetState) => Action | Thunk
export type Dispatch = ReduxDispatch<Action> & (action: Thunk) => void
但如果您直接在 store
上发送,则不重新创建 store
将无法工作:
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>;
到目前为止,它在我的项目中对我来说效果很好,尽管我不会直接在任何地方的商店发货。