在Flutter Redux中比较旧视图模型和当前视图模型

时间:2019-06-02 22:22:01

标签: flutter flutter-redux

在Flutter-redux中,我们可以使用onDidChange和onWillChange来检测商店状态的变化。但是有办法检测特定属性的变化吗?

我可以做类似的事情

if(oldViewModel.changedProperty != viewModel.changedProperty)

在react-redux中,可以检查prevProps和currProps的差异并基于此差异执行操作。

1 个答案:

答案 0 :(得分:0)

// As a performance optimization, the Widget can be rebuilt only when the
// [ViewModel] changes. In order for this to work correctly, you must
// implement [==] and [hashCode] for the [ViewModel], and set the [distinct]
// option to true when creating your StoreConnector.

StoreConnector<AppState, AppState>(
              distinct: true,
              converter: (store) => store.state,
              builder: ),