Skip to content

When modeling with @observable decorator #3288

Answered by kubk
codemilli asked this question in Q&A
Discussion options

You must be logged in to vote

Mobx skips converting unknown classes. You can check it by running console.log(isObservable(this._image)). It'll give false.

I want autorun is called when image is loaded, so I did modeling like below

No need to use autorun for that. You can collocate event with reaction like this:

loadImage(image: HTMLImageElement) {
  // run code from autorun
}

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@codemilli
Comment options

@codemilli
Comment options

@kubk
Comment options

kubk Feb 20, 2022
Maintainer

@codemilli
Comment options

@kubk
Comment options

kubk Feb 20, 2022
Maintainer

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