Skip to content

Instantly share code, notes, and snippets.

@jonotron
Created November 29, 2012 04:33
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jonotron/4166811 to your computer and use it in GitHub Desktop.
Save jonotron/4166811 to your computer and use it in GitHub Desktop.
marionette.application singleton pattern
// usage:
// var app = require('singleton');
define(function(require) {
var Marionette = require('backbone.marionette');
// static instance of a Marionette.Application
var app = null;
// singleton function
function getSingleton() {
if (app === null) {
app = new Marionette.Application();
}
return app;
}
// the app/singleton module returns the results of the singleton function
return getSingleton();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment