alibaba / fish-redux

An assembled flutter application framework.
https://github.com/alibaba/fish-redux
Apache License 2.0
7.33k stars 843 forks source link

Reducer只被调用了一次 #560

Closed halower closed 4 years ago

halower commented 4 years ago

我想实现下拉刷新的测试,当我在Reducer中返回null,每次dispatch都可以进出,只是没有数据,但是如果我按照下面的写法,只有第一次可以正常加载,但是后面就不会再次进入Reducer里面了,不知道为什么? 算不算bug呢?

//Action
  ...

  static Action onLoadMoreAction() {
    return  Action(MessageAction.onLoadMore);
  }

// Reducer

MessageState _loadMoreMessageReducer(MessageState state, Action action) {
   final List<Message> messages = [
     Message(content: DateTime.now().microsecondsSinceEpoch.toString())
   ];
   return state.clone()..messages = (state.messages.toList()..addAll(messages));
}

//View

 void _onLoading() {
    dispatch(MessageActionCreator.onLoadMoreAction());
    _refreshController.loadComplete();
  }