Angular2和Redux Thunk中的异步操作
我正在尝试在angular2应用程序中使用redux和redux thunk实现异步操作(用于异步http请求)。因此,我想对异步操作使用redux thunk,如中所述 我可以在不使用redux thunk的情况下运行应用程序,只需遵循本教程: 在应用程序组件中应用redux thunk,如:Angular2和Redux Thunk中的异步操作,angular,redux,redux-thunk,Angular,Redux,Redux Thunk,我正在尝试在angular2应用程序中使用redux和redux thunk实现异步操作(用于异步http请求)。因此,我想对异步操作使用redux thunk,如中所述 我可以在不使用redux thunk的情况下运行应用程序,只需遵循本教程: 在应用程序组件中应用redux thunk,如: let store: Store<AppState> = createStore<AppState>( clientReducer, applyMiddleware(th
let store: Store<AppState> = createStore<AppState>(
clientReducer,
applyMiddleware(thunk),
devtools
);
let-store:storeapplyMiddleware(thunk.default)是否帮助编译类型脚本?有时,typescript导入在某些库如何使用其默认导出方面效果不佳。另外,如果您可以链接完整文件以了解如何导入Thunk,则可能会有所帮助。完整文件是:我也尝试过:const Thunk=require('redux-Thunk')。默认值;这是我使用过的文件,请尝试使用applyMiddleware(thunk.default)谢谢您的信息。但我没有React应用程序,只有Angular2。我的错误是一个typescript“generic type”错误,特定于Angular2。因此,您的代码当然可以工作,但不能解决我的问题。无论如何,谢谢:-)我自己到目前为止还没有找到解决方案,因此将我的实现从普通redux更改为angular2 redux,采用了这个示例应用程序:doing`applyMiddleware(thunk.default),`是否帮助typescript编译?有时,typescript导入在某些库如何使用其默认导出方面效果不佳。另外,如果您可以链接完整文件以了解如何导入Thunk,则可能会有所帮助。完整文件是:我也尝试过:const Thunk=require('redux-Thunk')。默认值;这是我使用过的文件,请尝试使用applyMiddleware(thunk.default)谢谢您的信息。但我没有React应用程序,只有Angular2。我的错误是一个typescript“generic type”错误,特定于Angular2。因此,您的代码当然可以工作,但不能解决我的问题。无论如何,谢谢:-)我自己到目前为止还没有找到解决方案,因此我的实现从普通redux更改为angular2 redux,采用了这个示例应用程序:
Error TS2345: Argument of type 'typeof 'redux-thunk'' is not assignable to parameter of type 'Middleware'.
Type 'typeof 'redux-thunk'' provides no match for the signature '<S>(api: MiddlewareAPI<S>): (next: Dispatch<S>) => Dispatch<S>'