Created
October 13, 2011 16:56
-
-
Save tommedema/1284787 to your computer and use it in GitHub Desktop.
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
<script data-main="./js/bootstrap" src="./lib/require.js"></script> |
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
/* | |
Bootstrap is responsible for: | |
> maintaining a list of all active routines | |
> setting up global event broker (mediator) | |
> loading routines | |
*/ | |
require(['require', './mediator'], function(require, mediator) { | |
//set all routines | |
var routines = [ | |
'./routines/test' | |
]; | |
console.log('bootstrap mediator: %o', mediator); | |
//load all routines | |
require(routines, function() { | |
//event: boot.init | |
mediator.emit('boot.init'); | |
//event: boot.initialized | |
mediator.emit('boot.initialized'); | |
}); | |
}); |
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
/* | |
* Mediator: global event broker | |
*/ | |
define(function() { | |
return new EventEmitter2({wildcard: true});; | |
}); | |
/* | |
* EventEmitter2 follows here (latest commit fa81d00d7a2ab9790cec3dccdb4411cde1896438) follows | |
*/ | |
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
define(['../mediator'], function(mediator) { | |
console.log('test routine loaded, mediator: %o', mediator); | |
mediator.once('boot.initialized', function() { | |
console.log('boot initialized fired in test routine'); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment