- The mediator pattern for centralized Pub/Sub
- Facade pattern for security/permissions
- AMD modules (great for modular development)
- Backbone.js & Underscore.js for MVC structure
- jQuery 1.7
- Templating via jQuery.tmpl (although this can be switched out for any other templating solution)
The application is broken down into AMD modules that contain distinct pieces of functionality (eg. views, models, collections, app-level modules). The views publish events of interest to the rest of the application and modules can then subscribe to these event notifications.
subscriptions go through a facade (or sandbox). What this does is check against the subscriber name and the 'channel/notifcation' it's attempting to subscribe to - if a subscriber doesn't have permissions to do this (something established through permissions.js), the subscription isn't allowed through. The rest of the application is however able to continue functioning.
For demonstration, see the permissions manager (permissions.js). By changing say, permissions -> renderDone -> todoCounter to be false, you can completely disable that component from displaying counts (because it isn't allowed to subscribe to that event). The rest of the Todo app can still however be used without issue. Nifty, eh?
The most important part of this application can be found in the
app/scripts/backbone/todo directory. This contains the AMD formatted models, views and collections needed. It also contains the mediator (mediator.js) providing pub/sub and a modules.js file containing subscribers consuming events broadcast (published) from the views.
app/scripts/util contains a set of helpers for module loading and execution. Note that whilst this demo does use these helpers, this isn't absolutely required for successfully creating Backbone applications using AMD modules. For an alternative approach to this, see .
For more information on writing applications using AMD modules see 
Based on portions by Ryan Rauh