Subscribing to arrays #575
Replies: 1 comment
-
If you want to accept both My preference for mutable array is to 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
-
I understand why
subscribe(store.arrayOfValues, ...)
breaks whenstore.arrayOfValues = [...]
is assigned. I also understand whysubscribeKey(store, 'arrayOfValues')
doesn't trigger whenstore.arrayOfValues.push(...)
is used. To handle both interactions withstore.arrayOfValues
you thus get this 'crazy' dance of having to do thesubscribe
inside (and outside) yoursubscribeKey
handler... which gets messy (the messy part is in particular the unsubscribe handling, do I need to unsubscribe? Now that I think about it I probably don't?).What I basically wanted to ask is: Am I doing this wrong? How are you guys handling this? Before looking at the implementation of
subscribeKey
I was expecting it to fire on anything happening 'inside' the key as well. Right now I am thinking of just creating my ownsubscribeKey
handler with a flag whether or not to subscribe to the targeted object, but wanted to ask around first.Beta Was this translation helpful? Give feedback.
All reactions