Hey there,
We ran into some unexpected behaviors with equalityComparer in Knockout 3.4
both with deferred updates on and off, and realized this was actually a combination
of unexpected behavior from pre-3.4 and new unexpected behavior from 3.4 with
deferred updates.
These are exemplified here:
The fiddle in question sets up an observable array and binds to it with the `checked`
binding. It also creates a computed that depends on the list, and subscribes directly
to the list. Each one of these appends to a visible log to indicate that it has fired and
what value of the list it's seeing. Finally, we set a custom equality comparer and log
what it receives.
In 3.3 and 3.4 with no deferred updates, the equality comparer is never invoked. My
suspicion is that we've actually just been setting the comparer incorrectly all along.
In 3.4 with deferred updates, the comparer is used—but both its parameters are the
final version of the array, rather than having the version before the check that's currently
going into effect and the version after. So no matter how clever one wants to get, the
equality comparer will always return true for a deep comparison.
Not sure what the right move is here. Should I file an issue? Or is this expected
behavior? Is the setup of equalityComparer that I use incorrect anyway, regardless
of how deferred updates affect it?
Thanks,
Antonio
PS: We used to use knockout-deferred-updates with 3.3, which behaves the same