Forked from asciidisco/pubsub_with_requirejs_backbone.js
Created
February 23, 2016 08:34
-
-
Save abumuawiyah/c30667dfdbbc41addc99 to your computer and use it in GitHub Desktop.
PubSub with requirejs & backbone
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
// PubSub impl. with require.js & backbone.js | |
// events.js | |
define(['underscore', 'backbone'], function (_, Backbone) { | |
'use strict'; | |
var events = {}; | |
_.extend(events, Backbone.Events); | |
return events; | |
}); | |
// filea.js | |
define(['events'], function (events) { | |
'use strict'; | |
events.on('my:event', function (message) { | |
console.log('Received message: ', message); | |
}); | |
}); | |
// fileb.js | |
define(['filea', 'events'], function (filea, events) { | |
'use strict'; | |
events.trigger('my:event', 'My Message'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment