Shopify/batman — pull request #732 by nickjs (2013-05-24 19:35:09+00:00)
Title: Hashes Should Fire Change Events [BREAKING]

Currently, hashes fire `itemsWereAdded` whenever you call `set('foo')`. That would be fine, except for the fact that we have an observer that listens for `itemsWereAdded` and first needs to clean up the current value of `foo`, if there is one. By the time `itemsWereAdded` is fired, the underlying `SimpleHash` has already been updated, so we have no way of getting the old value.

In addition, `itemsWereAdded` becomes kind of a misnomer if the item already existed. It's not really an "add" at that point, just a change on a key that already exists. So we added an additional `itemsWereChanged` event that fires if the key already exists and is simply being changed.

That would be non-breaking on its own, but we also decided to make it only fire one event. I.e. if the key already existed, it will only fire `itemsWereChanged` and not fire `itemsWereAdded`. The latter will only fire if the key is being `set` for the first time. There are no cases in batman.js or Shopify where we rely on this behaviour, so I don't think it's particularly severely breaking, but... you know... maybe.

Does anyone else rely on the existing behaviour?

@hornairs @kristianpd
Paired with @SoapyIllusions