I have a state
object which has a property session
, this property can either be an object
or null
.
I don't want to have to dirty-check for the isSessionActive()
getter, so I'd like to use computedFrom()
. However, computerFrom()
doesn't seem to fire when this object changes, unless it was undefined
previously.
Can I do this without a dedicated isSessionActive
boolean property on my state Store?
@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;
}
}
I ended up just doing the following:
isSessionActive: boolean = false;
constructor(private store: Store) {
store.state.subscribe(
response => {
this.state = response;
this.isSessionActive = response.activeSession !== null;
}
)
}