大佬教程收集整理的这篇文章主要介绍了javascript – Aurelia的computedFrom与一个对象,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一个具有属性会话的状态对象,该属性可以是对象或null.
我不想对isSessionActive()getter进行脏检查,所以我想使用computedFrom().但是,当此对象更改时,computerFrom()似乎不会触发,除非之前未定义.
如果我的州商店没有专门的isSessionActive布尔属性,我可以这样做吗?
@autoinject
export class Home {
firstName: string = "user";
private state: State;
constructor(private store: Store) {
store.state.subscribe(
response => this.state = response
)
}
@computedFrom('state.activeSession')
get isSessionActive() {
return this.state.activeSession !== null;
}
}
isSessionActive: boolean = false;
constructor(private store: Store) {
store.state.subscribe(
response => {
this.state = response;
this.isSessionActive = response.activeSession !== null;
}
)
}
以上是大佬教程为你收集整理的javascript – Aurelia的computedFrom与一个对象全部内容,希望文章能够帮你解决javascript – Aurelia的computedFrom与一个对象所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。