1

我对颤动和尝试颤振 redux 库有点陌生,但我坚持有一个适当的中间件列表。

import 'package:flutter_app/incrementButtonScreen/IncrementButtonActions.dart';
import 'package:flutter_app/incrementButtonScreen/IncrementButtonLogicStates.dart';
import 'package:flutter_app/incrementButtonScreen/IncrementButtonState.dart';
import 'package:redux/redux.dart';

List<Middleware<IncrementButtonState>> createIncrementButtonStoreMiddleware = [
  TypedMiddleware<IncrementButtonState, Increment>(createIncrement("typed")),
  createIncrement("normal")
];

Middleware<IncrementButtonState> createIncrement(String logger) {
  return (Store store, action, NextDispatcher next) {
    print('\n ACTION $logger : ${new DateTime.now()}: $action');
    // some api call happening here and passing the APi call result next
    next(IncrementButtonLogicIncrementState(220, 15.0));
  };
}

问题是,我只从普通的中间件获取日志,但从不从输入版本获取日志。我正在尝试修改反例并class Increment{}在 fab click 上调度操作store.dispatch(Increment); 我在这里创建我的商店:

Store createIncrementButtonStore() {
  return new Store<IncrementButtonState>(_counterReducer,
      initialState: IncrementButtonState.initial(), middleware: createIncrementButtonStoreMiddleware);
}

当我替换TypedMiddleware<IncrementButtonState, Increment>TypedMiddleware<IncrementButtonState, dynamic>then 我得到它的工作原理

ACTION typed : 2018-08-06 12:04:45.778293: Increment
     ACTION normal : 2018-08-06 12:04:45.778411: Instance of 'IncrementButtonLogicIncrementState'
4

1 回答 1

0

经过长时间的搜索,我发现我正在调度Increment,它相当于 java 中的 Increment.class 我相信,调度后Increment()它工作正常

于 2018-08-06T10:33:28.020 回答