7 ms·
Backbone.js 1.1 is out
- bratsche 13y agoFor anyone who's looking for the changelog, it's at the bottom of the page so it's easy to miss. * Made the return values of Collection's set, add, remove, and reset more useful. Instead of returning this, they now return the changed (added, removed or updated) model or list of models. * Backbone Views no longer automatically attach options passed to the constructor as this.options, but you can do it yourself if you prefer. * All "invalid" events now pass consistent arguments. First the model in question, then the error object, then options. * You are no longer permitted to change the id of your model during parse. Use idAttribute instead. * On the other hand, parse is now an excellent place to extract and vivify incoming nested JSON into associated submodels. * Many tweaks, optimizations and bugfixes relating to Backbone 1.0, including URL overrides, mutation of options, bulk ordering, trailing slashes, edge-case listener leaks, nested model parsing...
- byroot 13y agoI don't think I'm very picky about versions meanings. But still the first two items are huge breaking changes for a dot release... If I hadn't left my previous job, It would take me a day or two to upgrade. Even Rails 3.2 => 4 is more straightforward.
- look_lookatme 13y agoI can't speak to the Backbone.js changes, but isn't one of the odd things about Rails versioning the fact that 3.x -> 4.0 is essentially a dot release upgrade, but 4.0 to 4.1 a full version upgrade (many things are deprecated from 3.x to 4.0, and 4.1 will remove them entirely?)
- steveklabnik 13y agoThat was the plan, but now we are planning to make 4.1 an easy upgrade as well, and not remove deprecations that were originally planned on being removed.
- look_lookatme 13y agoOh that's awesome. Thanks for the info.
- masterj 13y agoHow? * Made the return values of Collection's set, add, remove, and reset more useful. Instead of returning this, they now return the changed (added, removed or updated) model or list of models. Given that calling `collection.add(foo)` returned `collection`, when were you ever using the return value for anything? Going forward you might, but I would be very surprised if much if any code was broken by this. * Backbone Views no longer automatically attach options passed to the constructor as this.options, but you can do it yourself if you prefer. This might require going through your code base, but it's just adding one line in the `initialize` function: initialize: function(options) { this.options = options; Annoying if you have hundreds of views that directly extend Backbone.View, but not something that should take a day to fix? Am I missing something?
- tbranyen 13y agoYou're missing a lot, but you would have had to peruse the commits that have been happening over the past year to know how much has changed. I'm not sure how to proceed with my own LayoutManager plugin. Hoping someone will PR a fix making it compatible, because my initial attempt told me it wasn't going to be trivial.
- masterj 13y agoWhat are the issues you're seeing with LayoutManager? Are they reflected in the changelog or hidden in commit messages?
- masterj 13y agoLooking into it, it seems like most of your issues stem from the fact that you depended on View._configure being called during initialization. You overwrite it here: https://github.com/tbranyen/backbone.layoutmanager/blob/master/backbone.layoutmanager.js#L855 https://github.com/tbranyen/backbone.layoutmanager/blob/mast... but this was completely removed with the update: https://github.com/jashkenas/backbone/compare/1.0.0...1.1.0#diff-0d56d0d310de7ff18b3cef9c2f8f75dcL983 https://github.com/jashkenas/backbone/compare/1.0.0...1.1.0#... In backbone's defense, that wasn't part of its public API, but it does make updating challenging. I'll give it a try and see if I can be of some help.
- pselbert 13y agoThat is precisely why our apps are currently "stuck" on 0.9.10. The upgrade process for backbone is rather painful, as you end up hunting for "undefined" issues all over the place. Any change that renders my entire application broken should be a major version bump.
- roryokane 13y agoDirect link to the changelog you quote: http://backbonejs.org/#changelog http://backbonejs.org/#changelog
- jashkenas 13y agoHere's a direct link to the actual net changes: https://github.com/jashkenas/backbone/compare/1.0.0...1.1.0#diff-5 https://github.com/jashkenas/backbone/compare/1.0.0...1.1.0#...
- danabramov 13y agoWhere can I read more about changes related to nested model parsing and submodels? This is something I had to implement just a week ago, and I resorted to overriding `set`. I wonder if they made it easier, or if there is a builtin support for nested models of some kind.
- jashkenas 13y agoHappy to oblige. There's no built-in convention for it, but you can do something like this: parse: function(attrs) { this.friends = new PeopleCollection(attrs.friends); delete attrs.friends; return attrs; } ... assuming that friends is an array of JSON objects suitable to be transformed into Person models.
- danabramov 13y agoJeremy, thanks! I tried overriding Model's `parse` in 1.0 but wasn't satisfied because it seems to be called in some cases but not the others. (I can't recall a specific example right now; maybe it was parsing the collection from server, or creating a collection using constructor). Do you think there are drawbacks to overriding `set`? It seems to work well for me but I'd love to hear your opinion: https://gist.github.com/gaearon/6689379 https://gist.github.com/gaearon/6689379
- philfreo 13y agoIf you want something lightweight I'd go with the approach @jashkenas mentioned. But also might want to checkout: https://github.com/PaulUithol/Backbone-relational https://github.com/PaulUithol/Backbone-relational
- visarga 13y agoHow is Backbone faring against AngularJS these days ?
- twodayslate 13y agoor ember.js?
- jed_watson 13y agoThe opposing philosophies haven't changed - AngularJS really wants you to live in an AngularJS world and is a framework, whereas Backbone is more of a library and can be used to enhance your app (or parts of it) as well as providing structure. Subjectively, they're both very popular although Angular seems to be growing faster while Backbone has been mature for a while. If you're comparing them, remember it's apples and oranges - my company used Backbone recently in a mobile app and we loved the flexibility to use the parts that were helpful (Views, Events) without having any enforced application structure. It feels very light-weight but leaves much of the decisions up to the developer (there are frameworks like Marionette that provide more structure if you want it) On the other hand Angular (or Ember for that matter) is great when you want to use it to drive your entire UI, and makes a lot of sophisticated behaviour easy to set up. So I'd say they're very different solutions to client-side MV*, and not really competing. You'd use the one that suits your problem and how you want to build your app.
- vonseel 13y agoBackbone is so much lighter than these frameworks, it really can't be compared directly. Angular is very popular lately, but you have to do your own research of the available choices and determine which project best fits your needs.
- calebgilbert 13y ago"angular or backbone: what are startups using" (blog post and poll) https://blog.backlift.com/entry/front-end-frameworks https://blog.backlift.com/entry/front-end-frameworks
- rubiquity 13y agoThey try and solve the same problem with different levels of abstraction. I've gone full circle from Vanilla JS, to Backbone, to big monolithic frameworks like Ember and Angular and I've come back to Backbone. I think Backbone provides the right level of abstraction for the problems it solves. Angular and Ember I feel create their own problems.
- sidcool 13y agoNo direct link to Change log. :(
- hellosmithy 13y agohttp://backbonejs.org/#changelog http://backbonejs.org/#changelog