View on GitHub

backbone-torso

A holistic approach to Backbone applications

Torso API

View

Building block of the UI

Overridden methods from Backbone.View

DOM generation / rendering

Transition Logic

View state methods

Feedback

Life cycle methods

Life cycle state methods

Tracked/Child view methods

* methods you can override or extend to produce desired functionality

List View

Auto-manages many views based on a collection of models/cells

Overridden methods from View

Public methods invoked by list view on collection updates

Configuration set by initialize parameters only

Form View

View that uses a Form Model to do 2-way binding

Overridden methods from View

Model

Server-backed, event-producing object

Added polling api

Loading api

The Loading API is NOT added by default. Add it by calling:

Torso.Model = Torso.Model.extend(Torso.Mixins.collectionLoading(Torso.Model));

Form Model

Mediates between a model and an HTML form

Add model bindings

State inspecting methods

Auto-updating methods

Cell

Event-producing object

A cell has the exact same API as a Model except the functions concerning server-connection are now no-op’s.

No-op functions

If you set a Cell’s isModelCompatible field to true, Torso will throw exceptions instead of performing a no-op.

Router

Object that switches perspectives

Inherits Backbone’s Router API.

No added methods.

(Cache) Collection

Added cache api

Cache helper methods

Added polling api

Requester (Private) Collection

Added polling api

Note: requester collections do not have the added cache api but still maintains added custom api from the cache extension.

Nested Model and Nested Cell

The backbone-nested properties are added, allowing the objects to listen to changes and emit events concerning properties that are contained within objects or arrays. Normally, Backbone models can only trigger events concerning properties at the first level. If you choose to use this “Nested” behavior, understand that there are some performance hits that come with it.

Service Cell - a cell with a higher purpose

A service contains exactly the same API as a Cell. So why do we have it at all? The concept of a service was so important that we decided to copy it into another module, effectively renaming the cell as a service. A service is an event-emitting object that stands separate from the UI (as in the view layer or the DOM) but still stores state and acts as a player in the application. An example of a service would be an object whose responsibility would be to keep an eye on bandwidth issues and trigger an event if it got too bad. Or an object that writes to localstorage and manages the frontend “database”.

Events

Inherits Backbone’s Events API

Used to created application-level event bus