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: _
Created
April 16, 2013 02:54
-
-
Save jcreamer898/5392999 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define( [ "app/modulea" ], function ( modulea ) { | |
return { | |
init: function() { | |
modulea(); | |
}, | |
someFunction: function() { | |
} | |
}; | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require( [ "app/app" ], function( app ) { | |
app.init(); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | |
}; | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 dorequire('app/modeula')
.