mobx
mobx copied to clipboard
Reaction reacting to all changes in an array instead of just its length
I have an issue with Reactions, I just realized that the following code reacts to any changes in the todos array (ex. changing the title), I was expecting it only to change in response to changing the length of the array:
reaction(
() => ({length: this.todos.length}),
(length) => {console.log('something changed')}
)
I'm not sure if this is a bug or if it's the intended behavior? if it's the intended behavior, then how do I get a more fine grained control on the observables that trigger a reaction.
Please note that the reason I returned an object from the first function, is that I have other observables (unrelated to todos) besides length that I want to track.
I'm using mobX 2.5.1
Turns out I had a syntax error