Skip to content

Instantly share code, notes, and snippets.

@jcreamer898
Created April 16, 2013 02:54
Show Gist options
  • Save jcreamer898/5392999 to your computer and use it in GitHub Desktop.
Save jcreamer898/5392999 to your computer and use it in GitHub Desktop.

I was thinking that through the use of the require in modulea, I'd be able to get a reference to the app based on what I thought I understood from http://requirejs.org/docs/api.html#circular. But, apparently I am wrong? :) Instead I get Uncaught Error: Module name "app" has not been loaded yet for context: _

define( [ "app/modulea" ], function ( modulea ) {
return {
init: function() {
modulea();
},
someFunction: function() {
}
};
});
require( [ "app/app" ], function( app ) {
app.init();
});
define( [ "require", "app/app" ],
function( require, app ) {
//"a" in this case will be null if a also asked for b,
//a circular dependency.
return function( title ) {
return require( "app" ).someFunction();
};
}
);
@jrburke
Copy link

jrburke commented Apr 16, 2013

I'm not sure I follow, I think you wanted to say require('app/app') inside modulea. If that is the case, then in app.js, I would also do require('app/modeula').

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment