Comments (3)
huh? You lost me -- could you provide a small code sample of what you're talking about?
from ender.
If I wanted to build a package that keeps track of all of the modules loaded:
(function () {
var modules = [],
$ = require('ender');
// called just before the module is loaded
$.provide.before = function (moduleName) {
modules.push(moduleName);
};
// callback would have the value of the module's module.exports
$.provide.after = function (module) {
// or do something smarter, like getting data from modules
if (init in module) {
module.init();
}
};
module.exports = modules;
}());
This is just a simple example. If events were used, this would be even better, since multiple packages could use the events:
(function () {
var modules = [],
$ = require('ender');
$.on('provide', function (moduleName, module) {
// some distinguishing feature
if (init in module) {
modules.push(moduleName);
module.init(moduleName);
}
});
module.exports = modules;
}());
I can see this being useful for people (like myself) that want to put all of their code in ender, but their code is modular, so they can't depend on all modules being there. Instead of a messy try-catch, they can just use a module db to keep track of modules they're interested in.
This same idea can be used in development to create a test-suite that performs unit tests on modules in a browser environment. This could help automate testing between browsers.
What do you think about it?
from ender.
Alright -- sorry for taking so long to get back to you!
That makes sense now -- thanks for clearing it up.
I think i would prefer this to live outside the ender-js library. In fact -- i feel like this would be a perfect "plugin" for ender (as a separate package).
Just wrap the original provide and require methods, and make sure you build the plugin into your ender lib first :)
Doing that will give you lots more room to add a proper event system and all that hottness -- stuff we couldn't really get away with adding here. Sound good?
I'm going to close this -- but feel free to reopen if you would like to continue to make it's case to be added to the core of the lib.
from ender.
Related Issues (20)
- Multiple ender add with the same package creates a weird build command.
- ender add fails when build is not run before HOT 1
- "ender compile" produces broken ender-app.js HOT 4
- Ender 1.1.0 no longer installs through npm HOT 1
- `refresh` command doesn't actually update modules HOT 3
- Ender 1.1.0 no longer includes auto-integration HOT 1
- AMD Loading Ender HOT 2
- Ender breaks requirejs optimiser. HOT 7
- Maintaining the selector property when passing an ender object as argument HOT 3
- Crash on Safari HOT 9
- Compiling Ender with underscore module results in "Uncaught TypeError: undefined is not a function"
- including relative dependencies + multiple directories
- Website is down HOT 3
- Ender cli - "ender info" fails when local packages are added as path like "package-folder/" HOT 1
- Use with WebPack HOT 1
- The package tap does not satisfy its siblings' peerDependencies requirements! HOT 3
- Is Ender mature or abandon? HOT 3
- Building alternative version of my lib
- Udacity
- Broken ender.min.js HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ender.