requirejs - callback when required file's requirements have completely finished evaluating -


sorry, i'm having tough time wording question.

essentially have file includeme.js:

require('anotherjs.js', function() {     console.log('yo, should print before "hello"'); } 

which required following require function:

require('includeme.js', function() {     console.log('hello, should printed second after "yo"'); }); 

i want of includeme.js evaluated before callback 'require'ing includeme.js. want yo logged before hello. is, includeme.js loaded, anotherjs.js loaded sync, meanwhile callback hello log called, before anotherjs finished being fetched , yo called.

is there way have callback waits js file evaluated requires returning?

the answer use requirejs recommend. define things requiring. in case of example:

require('anotherjs.js', function() {     console.log('yo, should print before "hello"'); } 

should be:

define('anotherjs.js', function() {      [...]      return false; } 

you want return meaningful, in case injecting controllers angular app, saw no reason define. guess require wait "define", won't wait "require". makes sense considering "define" per file , entwined requirejs, while require useful function.

so, don't dumb me, , make sure define plan require. if requiring prepares globals, use shims. recommended in requirejs documentation.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -