gleeman
Whats That?
- Dependency Injection Framework
- Dependency loader
- Module Manager
- Project architecture idea
Serverside Require.JS
- similar to AMD
- similar to Angulars DI
EXample
// FILE apps/core/myapp/index.js
module.exports = { func_one: function(func_oneDone) { // do something complicated here // of cause even async stuff is possible var result = 'func_one_result'; // call the callback, first parameter is the error, second // the result of this function func_oneDone(null, result); },
// this function depends on the upper on, so we have to mark this func_two: [ 'core:myapp:func_one', function(func_twoReady, resultFromOne) { // now we can use the result from above func_twoReady(null, resultFromOne + ' with 2'); } ] };
Follow ups
- Reverse Dependency
- normal DI: Do that before this
- Follow ups: Do this before that
- usefull for collectors: i. E. Javascript/CSS files/Routes
Simple Example
// FILE apps/core/myapp/index.js
module.exports = { func_one: [ function(func_oneDone) { var result = 'func_one_result'; func_oneDone(null, result); }, 'core:myapp:func_two' ], func_two: function(func_twoReady, results) { var resultFromOne = results['core:myapp:func_one']; func_twoReady(null, resultFromOne + ' with 2'); } };
Packages
- NPM modules for Gleeman
- Modules with async initializations
- Example: gleeman-express
Demo
gleeman
By Stephan Hoyer
gleeman
- 1,284