gmac / backbone.epoxy

Declarative data binding and computed models for Backbone
http://epoxyjs.org
MIT License
614 stars 89 forks source link

Unexpectedly early trigger of change #40

Closed tliao closed 10 years ago

tliao commented 11 years ago

Attempting to set a mix of computed and non-computed attributes on a model causes an unexpectedly early trigger of 'change' on the model. Normally this is triggered after all of the attributes have been set and all the 'change:attributes' have been fired.

With epoxy, set will call deepModelSet which eventually calls EpoxyComputedModel.change(). This triggers a 'change' event on the model as soon as it's called, regardless of whether the other non-computed attributes have been set yet.

gmac commented 11 years ago

Mer... yeah, I get what you're say and will put this at the top of my backlog to address.

gmac commented 10 years ago

Just an update... I do still consider this a priority issue; however it has deep and tricky enough implications that it's not a quick and easy item to sit down and address.

tliao commented 10 years ago

No worries; I would've offered a pull request but I realized it was deeper than I was comfortable with.

I ended up treating the need to have change events fired in a particular order as a code smell on my end and used custom events to work around it.

Would still like to see it fixed, but it's not blocking me so take your time :)

gmac commented 10 years ago

This should be fixed, see 2d46296. All event triggers are now deferred until the entire set operation runs. Computed attributes simply log an event to be triggered while setting rather than firing off immediately. Computed attributes should also now honor a {silent: true} option, which they apparently didn't before.

tliao commented 10 years ago

Great thanks! :)