redux - Flutter Redux Middleware
问题描述
I'm completely new to redux and it's beginning to make sense. I'm trying to use the middleware to keep the reducer a pure function but it's giving me an error I don't understand. I'm following the flutter architecture samples for redux
void main() {
final store = Store<AppState>(
appReducer,
initialState: AppState.loading(),
middleware: createStoreFlashCardsMiddleware(),
);
runApp(new MyApp(store));
}
//the middleware
List<Middleware<AppState>> createStoreFlashCardsMiddleware() {
final loadFlashCards = _createLoadFlashCardsMiddleware();
final saveFlashCards = _createSaveFlashCardsMiddleWare();
return [
TypedMiddleware<AppState, FetchFlashCardsAction>(loadFlashCards),
TypedMiddleware<AppState, AddFlashCardAction>(saveFlashCards),
TypedMiddleware<AppState, ClearCompletedAction>(saveFlashCards),
TypedMiddleware<AppState, ToggleAllAction>(saveFlashCards),
TypedMiddleware<AppState, UpdateFlashCardAction>(saveFlashCards),
TypedMiddleware<AppState, FetchCardsSucceededAction>(saveFlashCards),
TypedMiddleware<AppState, DeleteFlashCardAction>(saveFlashCards),
];
}
Middleware<AppState> _createSaveFlashCardsMiddleWare() {
return (Store store, action, NextDispatcher next) async {
// YOUR LOGIC HERE
// After you do whatever logic you need to do,
// call this Redux built-in method,
// It continues the redux cycle.
next(action);
};
}
Middleware<AppState> _createLoadFlashCardsMiddleware() {
return (Store store, action, NextDispatcher next) async {
next(action);
};
}
The error is:
error: The argument type 'List<(Store<AppState>, dynamic, (dynamic) → void) → void> (C:\flutter\bin\cache\pkg\sky_engine\lib\core\list.dart)' can't be assigned to
the parameter type 'List<(Store<AppState>, dynamic, (dynamic) → void) → void> (C:\flutter\bin\cache\pkg\sky_engine\lib\core\list.dart)'. (argument_type_not_assignable at [line])
解决方案
推荐阅读
- html - BEM 正确嵌套,我不知道怎么写 css/less
- omnet++ - OMNET++ 将客户无线节点模块连接到 wlan
- ios - 如何从 Windows 在 Iphone 模拟器中部署应用程序
- c++ - 哪些整数运算不安全?
- java - 为什么我的代码不计算字符串的第一个单词
- c# - 自定义 ASP.NET 图表的样式
- python - 查找具有共同起始元素的子列表 - python
- angular - 跨设备渲染 Angular 的实时变化
- hyperledger-fabric - 无法在 Composer Rest Server 中过滤数据
- authentication - ODBC 中的 InitString SqlAnywhere 12 身份验证