【问题标题】:Compare old view model and current view model in Flutter redux比较 Flutter redux 中的旧视图模型和当前视图模型
【发布时间】:2019-06-02 22:22:01
【问题描述】:

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

我可以做类似的事情

if(oldViewModel.changedProperty != viewModel.changedProperty)

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

【问题讨论】:

  • 这对你有用吗?我面临同样的问题,并且我总是拥有具有相同值的新旧 ViewModel

标签: flutter flutter-redux


【解决方案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: ),

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2010-12-07
    • 2014-01-03
    • 2012-01-18
    • 1970-01-01
    • 2017-09-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多