Comments (4)
@dmgr just use modulejs.require()
for that..
from modulejs.
It doesn't work, because if you have this order of code snippets:
modulejs.require('lib_a', function(lib_a) {
console.log('using lib_a');
});
modulejs.define('lib_a', function() {
console.log('lib_a loaded');
return {};
});
You will have a:
Uncaught Error: [modulejs-32] id not defined "lib_a"
The hypothetical "modulejs.run" function might work thanks to observers working in "modulejs.define" function and when that observer will recognize that all libraries are defined to run particular code snippet defined by "modulejs.run" method, it will fire it.
Of course "module.require" can work like that so then "modulejs.run" wouldn't be necessary.
from modulejs.
That will not work at all, as require
expects a single id
argument only, no callback.
I think the best way to run your code is after all js is loaded, for example:
document.addEventListener('DOMContentLoaded', function () {
var app = modulejs.require('main');
app.start();
});
or with jQuery:
jQuery(function () {
var app = modulejs.require('main');
app.start();
});
but I understand your request now..
from modulejs.
Yes, I thought about that solution and I think it will be done using that workaround.
Anyway, something like:
modulejs.require(['lib_a', 'lib_b'], function(lib_a, lib_b) {
lib_a.start();
})
or/and:
modulejs.require(['lib_a', 'lib_b'], function() {
var lib_a = modulejs.require('lib_a');
lib_a.start();
})
in addition to:
var lib_a = modulejs.require('lib_a');
lib_a.start();
would be cool ;)
from modulejs.
Related Issues (8)
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 modulejs.