I have two State(store) classes with observable members. Both domains use a common set of data listHeaders. It seems to me that the best structure would be a third class with a listHeaderobservable, and a way to define observable aliases on my two State classes.
class A {
@observable listHeaders = [];
}
class B {
@observable.alias listHeaders = a.listHeaders;
constructor(private a: A) {}
}
class C {
@observable.alias listHeaders = a.listHeaders;
constructor(private a: A) {}
}
You'd be able to assign listHeaders anywhere and fire a change everywhere since all three listHeaders are actually the same observable.
I haven't seen a way to do this. Perhaps I missed it.
class C {
constructor(private a: A) {}
get listHeaders() {
return this.a.listHeaders;
}
set listHeaders(listHeaders) {
return this.a.listHeaders = listHeaders;
}
}
Why not to expose a on B/C?
closing as answered
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs or questions.
Most helpful comment
Why not to expose
aonB/C?