Skip to content

Why don't getters use cached value when accessed directly? #2161

Discussion options

You must be logged in to vote

So here is where we set up the getters. It calls makeObservable from MobX with these options:

makeObservable(self, { [key]: computed } as any)

Which is also calling the MobX computed option here: https://mobx.js.org/computeds.html

Computed values can be used to derive information from other observables. They evaluate lazily, caching their output and only recomputing if one of the underlying observables has changed. If they are not observed by anything, they suspend entirely.

I don't know enough about the MobX codebase to actually say how this interaction happens. That's on them. But since MST is built on top of MobX, their runtime behavior becomes ours, haha.

Replies: 2 comments 8 replies

Comment options

You must be logged in to vote
3 replies
@coolsoftwaretyler
Comment options

@dbstraight
Comment options

@coolsoftwaretyler
Comment options

Comment options

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

@coolsoftwaretyler
Comment options

Answer selected by coolsoftwaretyler
@coolsoftwaretyler
Comment options

@dbstraight
Comment options

@coolsoftwaretyler
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
2 participants