a flutter redux test demo.
List<NextDispatcher> _createDispatchers(
List<Middleware<State>> middleware,
NextDispatcher reduceAndNotify,
) {
final dispatchers = <NextDispatcher>[]..add(reduceAndNotify);
// Convert each [Middleware] into a [NextDispatcher]
for (var nextMiddleware in middleware.reversed) {
final next = dispatchers.last;
dispatchers.add(
(dynamic action) => nextMiddleware(this, action, next),
);
}
return dispatchers.reversed.toList();
}
- state reduce函数中必须创建新的对象。如果不创建,始终不会受到更新的通知(即使有相关的==重载)
- 换句话说,创建新对象后,不需要重载==,就可以达到通知变更的信息。