I would store the "current" attributes in your controller and track changes to the model (via model 'update' events), iterating through attributes to check for equality.
It feels right to put it in my own business logic because 1) you usually only care about tracking a few items (eg. the selected one) 2) tracking field changes unnecessarily complicates the framework, and 3) the REST way is to send all of the attributes with an update, so internally it would have to check for equality on each field anyway.
Also, you can update your models independently of views, as many times as you want, and this is a good thing. How would the model know which views have "recognized" the change if you updated something more than once since it was last visible?
Wherever you deal with update/render you should be able to handle this kind of UI sugar, and it would be easier there than tracking version history in the model.
Unless I missed the point :)
Ian
Sent from my iPhone
Spine handles update events on models, so I think you are talking about an event per field change?
I would store the "current" attributes in your controller and track changes to the model (via model 'update' events), iterating through attributes to check for equality.
It feels right to put it in my own business logic because 1) you usually only care about tracking a few items (eg. the selected one) 2) tracking field changes unnecessarily complicates the framework, and 3) the REST way is to send all of the attributes with an update, so internally it would have to check for equality on each field anyway.
Also, you can update your models independently of views, as many times as you want, and this is a good thing. How would the model know which views have "recognized" the change if you updated something more than once since it was last visible?
When a record is saved, Spine automatically creates an ID if it doesn't already exist.
assertEqual( contact.id, "AD9408B3-1229-4150-A6CC-B507DFDF8E90" )
Changes are only tracked upon persistence, and I think it is understood that when a model is saved it is given an id. (Does spine even support alternative primary keys? Does anyone still do that?) Also, spine gives an id automatically upon save: http://spinejs.com/docs/modelsWhen a record is saved, Spine automatically creates an ID if it doesn't already exist.
assertEqual( contact.id, "AD9408B3-1229-4150-A6CC-B507DFDF8E90" )It looks like both giving the change data to the callback and firing a universal 'changed' event would be easy to add. I notice you've given it its own repo-- would you accept those as pull requests?One thought-- if a general event is fired on change (giving all the changes), it would have to be 'changed' as updated is already used. And so it stands that the update:attr event should become changed:attr.Cheers,--Peter