Core Backbone Components

In notebook:
FrontEndMasters BackboneJS
Created at:
2016-02-13
Updated:
2016-02-13
Tags:
JavaScript jQuery libraries Fundamentals

Models & Collections

Separate interface for managing data on the client side.
Model: Smallest level of granularity, like a row in a database
Collections:  models" and the ability to act on those

Custom events

An easy way to deal with changing data in app.
(Note: Henrik Joreteg warns about overusing events, in another FEM workshop)
Notify one object another. It's like click event handlers in the DOM. (You don't know when it happens, but want a handler to act on it).

Sync

Single point of entry for all AJAX requests.
Customise things like server setup, or integrating with third-party services. 

Views

Event delegation for free.
jQuery is not efficient when there are hundreds of "target" items to attach event handlers. Event delegation is much more efficient

Developers Ergonomics

Code that's easier to test

Backbone works best when...

  • There's a RESTful architecture on the server (that's how Backbone is set up)
  • You're willing to do things the Backbone way. It teaches you a lot about JavaScript. Code organisation, object instances, object creation.
  • Keep in mind there's more than one way