Created
July 14, 2014 20:39
-
-
Save cod3beat/f8fd13f0a12eec423e2e to your computer and use it in GitHub Desktop.
MessageBus yang di ekstrak dari MarionetteJS
This file contains hidden or 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
define(function(require) { | |
'use strict'; | |
var Backbone = require('backbone'), | |
Wreqr = require('backbone.wreqr'), | |
_ = require('underscore'); | |
function MB() { | |
this.vent = new Wreqr.EventAggregator(); | |
this.commands = new Wreqr.Commands(); | |
this.reqres = new Wreqr.RequestResponse(); | |
} | |
_.extend(MB.prototype, Backbone.Events, { | |
execute: function() { | |
this.commands.execute.apply(this.commands, arguments); | |
}, | |
request: function() { | |
return this.reqres.request.apply(this.reqres, arguments); | |
}, | |
close: function() { | |
this.commands.removeHandler(); | |
this.reqres.removeHandler(); | |
this.vent.off(); | |
} | |
}); | |
var mb = new MB(); | |
return mb; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment