observable.array excess triggers? #2811
Answered
by
mweststrate
alexandroppolus
asked this question in
General
Replies: 3 comments 1 reply
-
This works as intended, arrays themselves are considered a single atom.
This is an optimization decision that makes cases like this slower, but
scenarios like looping or shifting items much faster. If per-key
subscriptions are important, use maps insteads.
…On Wed, Feb 17, 2021 at 8:58 AM Alexandroppolus ***@***.***> wrote:
Hi!
***@***.***
const arr = observable.array([0, 0])
autorun(() => {
console.log('arr[0] === ' + arr[0])})// print "arr[0] === 0"
runInAction(() => {
arr[1] = 1})// print "arr[0] === 0" WTF???
autorun observes to arr[0]. Why it triggers on change arr[1]?
If using observable.object({ 0: 0, 1: 0 }), all good, autorun not
triggers.
With regards,
Alex
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#2811>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAN4NBA42HPEGMY7WBNVN4DS7OAKLANCNFSM4XX6PKXQ>
.
|
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
alexandroppolus
-
correct
…On Wed, Feb 17, 2021 at 10:16 AM Alexandroppolus ***@***.***> wrote:
Ok, thanks.
I also noticed similar behavior in observable.set. This are also a single
atom?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#2811 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAN4NBERUC26LG6ZGQI4NA3S7OJORANCNFSM4XX6PKXQ>
.
|
Beta Was this translation helpful? Give feedback.
0 replies
-
The difference between three case.use
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi!
mobx@6.1.6
autorun
observes toarr[0]
. Why it triggers on changearr[1]
?If using
observable.object({ 0: 0, 1: 0 })
, all good,autorun
not triggers.With regards,
Alex
Beta Was this translation helpful? Give feedback.
All reactions