在Flutter Redux中比较旧视图模型和当前视图模型 [英] Compare old view model and current view model in Flutter redux
本文介绍了在Flutter Redux中比较旧视图模型和当前视图模型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在Flutter-redux中,我们可以使用onDidChange和onWillChange来检测存储状态的变化.但是有办法检测特定属性的变化吗?
In Flutter-redux, we can use onDidChange and onWillChange to detect changes in store state. But is there a way to detect change in particular properties?
我可以做类似的事情
if(oldViewModel.changedProperty != viewModel.changedProperty)
在react-redux中,可以检查prevProps和currProps的差异,并据此执行操作.
In react-redux, prevProps and currProps can be checked for differences and perform action based on that.
推荐答案
// 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: ),
这篇关于在Flutter Redux中比较旧视图模型和当前视图模型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文