在NGRX中选择和没有选择之间有什么区别?
当我订阅商店的状态时,我通常使用两种方法。 它们之间有什么区别吗(比如性能什么的)
constructor(private store : Store<MyState>){
//1
this.store.pipe(select(x=>x.myComplexObject)).subscribe(x=> {
this.data = x;
})
//2
this.store.subscribe(x=> {
this.data = x.myComplexObject;
})
}
I have two ways usually use when I subscribe to a state of a store.
Is it any difference between them (like performance or something)
constructor(private store : Store<MyState>){
//1
this.store.pipe(select(x=>x.myComplexObject)).subscribe(x=> {
this.data = x;
})
//2
this.store.subscribe(x=> {
this.data = x.myComplexObject;
})
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
两者都是一样的。
但是,我建议您搬到
选择器
,因为这些优点具有多个优点:https://ngrx.io/guide/store/selectors
Both are the same.
But, I would suggest moving to
selectors
because these have several advantages:https://ngrx.io/guide/store/selectors