4 ms·
Notice how this carefully doesn't use silent: true, seeing as in the latest version of Backbone, they have repurposed the silent option for completely different
by robinduckett 15y ago
Notice how this carefully doesn't use silent: true, seeing as in the latest version of Backbone, they have repurposed the silent option for completely different functionality.
- jashkenas 15y agoNot quite. (Although you and I have certainly discussed this plenty on GitHub.) For folks who haven't been following along: Performing "silent" changes to a model are a power-user feature of Backbone, where you can twiddle attributes on a model temporarily, or many times, without receiving change events. Then, when you're ready, you get a single change event with the diff in model state. Prior to 0.9, you'd get the single diff, but not all of the individual "change:attribute" events for the diff. 0.9 and above have been improved to give you both. Yes, it's something to watch out for if you want to upgrade an existing app.
- robinduckett 15y agoThe problem is your complete unwillingness to compromise and to make it easier for people to upgrade an existing app. The way that silent works now should be it's own option, say "defer". Because you're deferring the changes until a later date. It could even be called delay or later. Whatever it is called, it is in no way silent anymore. My proposal is to add a new option, mute, which bypasses the change events and causes the attribute to change but does not trigger change:attribute. Edit: https://github.com/documentcloud/backbone/pull/981 https://github.com/documentcloud/backbone/pull/981
- jashkenas 15y agoWhile I appreciate the effort and persistence, having {silent: true, mute: true} be part of the model API is definitely not the direction that the Backbone API should be going. That said, what you do with your copy of backbone.js in your own project is your business. I'd highly encourage you to extend your version with your preferred behavior for "silent" -- in fact, the source is annotated to make this sort of thing easier for folks that find the need.