0

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

我可以做类似的事情吗

if(oldViewModel.changedProperty != viewModel.changedProperty)

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

4

1 回答 1

1
// 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: ),
于 2019-06-11T09:13:58.363 回答