Skip to content

Instantly share code, notes, and snippets.

@benhowdle89
Last active March 13, 2021 12:22
Show Gist options
  • Save benhowdle89/ba713a9a20fdf11870eb to your computer and use it in GitHub Desktop.
Save benhowdle89/ba713a9a20fdf11870eb to your computer and use it in GitHub Desktop.
Easy Singleton instances using Browserify
var _vent = require('./vent.js').shared();
_vent.trigger('blah');
var Backbone = require('backbone'); // or any Event/PubSub lib you prefer
var _vent = null;
module.exports = {
shared: function () {
if (!_vent) {
_vent = _.extend({}, Backbone.Events);
}
return _vent;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment