Skip to content

@timruffles /testable_vent.js
Last active

Embed URL


Subversion checkout URL

You can clone with
Download ZIP
testable 'global' vent - musing on easy dependency injection
var View = Backbone.View.extend({
constructor: function(opts) {
this.vent = (opts && opts.vent) || window.vent;
function Vent() {}
Vent.prototype = _.extend({},Backbone.Events);
// in production
window.vent = new Vent
var productionView = new View(); // implicit app vent
// in test
toTest = new View({vent: mockVent});
// in a sub-system with a specific vent
var subVent = new Vent
var subA = new View({vent: subVent});
var subB = new View({vent: subVent});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.