What is the functionality of onBecomeObserved
when property
(2nd arg) is omitted?
#3355
Answered
by
urugator
FirstWhack
asked this question in
Q&A
-
The relevant documentation doesn't seem to explain this, though we can see from the relevant code that the I am wondering what is the functionality of using onBecomeObserved(this, () => console.log('became observed');
onBecomeUnobserved(this, () => console.log('no longer observed'); |
Beta Was this translation helpful? Give feedback.
Answered by
urugator
Apr 4, 2022
Replies: 1 comment 3 replies
-
Depends on what But it can be observable.box(5) , observable.computed(() => {}) , createAtom() , observable([]) , observable(new Set()) , observable(new Map()) .In case of observable(new Map()) it reacts to subscriptions related only to the keys (addition/removal of key).
|
Beta Was this translation helpful? Give feedback.
3 replies
Answer selected by
FirstWhack
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Depends on what
this
is. If observable object it will probably throw:mobx/packages/mobx/src/types/type-utils.ts
Line 42 in d233eba
But it can be
observable.box(5)
,observable.computed(() => {})
,createAtom()
,observable([])
,observable(new Set())
,observable(new Map())
.In case of
observable(new Map())
it reacts to subscriptions related only to the keys (addition/removal of key).