Last active
March 13, 2021 12:22
-
-
Save benhowdle89/ba713a9a20fdf11870eb to your computer and use it in GitHub Desktop.
Easy Singleton instances using Browserify
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var _vent = require('./vent.js').shared(); | |
_vent.trigger('blah'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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