Skip to content

eliperelman/backbone-aura

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 

Repository files navigation

##Backbone-Aura

This repo demonstrates an (event-driven) Todo application using 2/3 of the concepts I discuss in my talks on large-scale JavaScript application development. This is the first time I've attempted to apply some of these concepts to Backbone.js, so the implementation may still require a few tweaks (and most likely does). That said, it uses:

  • The mediator pattern for centralized Pub/Sub
  • Facade pattern for security/permissions
  • RequireJS
  • 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)

Summary

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.

All 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?

Folders

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 [1].

For more information on writing applications using AMD modules see [2]

Based on portions by Ryan Rauh [3]

###References

About

Backbone.js integrated with AMD modules as well as the mediator & facade patterns

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%