Skip to content

MakeAutoObservable, Typescript, and nested ES6 classes #2849

Answered by urugator
micka190 asked this question in Q&A
Discussion options

You must be logged in to vote

Am I really supposed to explicitly make everything observable?

Yes, each class is responsible for annotating itself. Notice you're not only making the instance observable, but also modifying the prototype (functions become actions etc), so it's good idea to keep it colocated.
Also note that this recursion process uses observable(object), which creates an observable copy of the object, while makeAutoObservable(object) modifies the object directly.

Btw you're not nesting classes, but composing class instances. Nested or inner class usually refers to ability to define class as part of another class - usually accessible only to the outer class.

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by micka190
Comment options

You must be logged in to vote
1 reply
@urugator
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants