Replies: 1 comment 3 replies
-
Have you checked https://github.com/mobxjs/mobx/tree/main/packages/eslint-plugin-mobx#mobxmissing-make-observable ? |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
As the title says, I think it would be a nice feature to write a babel decorator to automate adding
makeObservable
to constructurs.It could work like this:
makeObservable
(or variants), otherwise bailmakeObservable(this)
into the constructor (and perhaps create a default constructor implementation if the class does not yet have one)I think this should be fairly simple to implement as a transformer and could make writing mobx code when using decorators as easy and straight-forward like when using mobx 4/5.
Another alternative I was thinking of would be writing a decorator which wraps the constructor call to automatically invoke
makeObservable
, but I think that might be error prone, because invokingmakeObservable
before the default ctor would probably not work and afterwards it might cause issues if observable fields are used in the constructor code, so I scrapped that idea.Beta Was this translation helpful? Give feedback.
All reactions