Version 0.4.1
A tiny modular architecture framework in JavaScript.
Inspiration : "Scalable JavaScript Application Architecture", by Nicholas C. Zakas.
- Video : http://www.youtube.com/watch?v=vXjVFPosQHw
- Slides : http://www.slideshare.net/nzakas/scalable-javascript-application-architecture-2012
Online demo : A simple todo list application
- Less than 2.5Kb minified
- Extensible
- Supports unit testing of the modules
- Supports async modules loading using AMD and require.js (less than 1Kb extension)
- Tested under IE7+, Safari 5.1, Opera 12, Chrome 24+ and Firefox 18+
- Decoupled application architecture
- Divide & conquer : each module implements only a functionality or a small set of functionalities
- Modules are independent : change/removal/failure of one does not affect the others
- Reusability : modules can be reused across a number of different applications
- Testing : modules can be tested individually both inside and outside of the application
Include TinyCore.js :
<script type="text/javascript" src="TinyCore.js"></script>
This will give you access to the global variable TinyCore
and its components : TinyCore.Module
, TinyCore.SandBox
and TinyCore.ErrorHandler
.
##Quick Start Guide
###1.- How to Register and Start a Module
See some examples in action: http://jsfiddle.net/juanma/eQ498/embedded/result/
See the code: http://jsfiddle.net/juanma/eQ498/
####1.1.- Register a Module
Before using a module we need to register it
// Register the Module
TinyCore.Module.register( 'my-module', function( bus ) {
return {
onStart: function( oData ) {
alert(oData.msg);
}
};
});
####1.2.- Start a Module
Once the module is registered, we can start it
TinyCore.Module.start("my-module", { msg : "Hello World!" });
###2.- How to Handle Events
See some examples in action: http://jsfiddle.net/juanma/Sjq4S/embedded/result/
See the code: http://jsfiddle.net/juanma/Sjq4S/
####2.1.- Subscribe to a Topic From one module we can listen to some "event"
// Register the Listener Module
TinyCore.Module.register( 'module-listener', function( oSandbox ) {
return {
onStart: function() {
oSandbox.subscribe ('my-topic', function(oTopic) {
alert(oTopic.data.msg);
});
}
};
});
####2.2.- Publish Topics From another module (or the same is listening this event) we can notify this "topic" (event)
// Register the Notifier Module
TinyCore.Module.register( 'module-notifier', function( oSandbox ) {
return {
onStart: function( oData ) {
oSandbox.publish ('my-topic', oData );
}
};
});
####2.3.- Stoping modules If we want to stop listening to "events" we can stop the module
TinyCore.Module.stop("my-module");
- Main dev : Mawrkus aka Marc Mignonsin (web@sparring-partner.be)
- JuanMa aka Juan Manuel Garrido (juanma.garrido@gmail.com)
- More demos
- Full API documentation
- More extensions
- Add a source map