Skip to content

Instantly share code, notes, and snippets.

@Tug
Created December 16, 2013 13:59
Show Gist options
  • Save Tug/7987337 to your computer and use it in GitHub Desktop.
Save Tug/7987337 to your computer and use it in GitHub Desktop.
`a.js` is called before `b.js`. (There is some asynchronous stuff going one between the 2 calls). Here Visit is going to be undefined when required in `b.js`, no error thrown. If I call `require_public('models/Visit')` at position 1, it works fine. Even in `b.js`, Visit will be defined (probably because it's kept in memory once loaded).
modules.exports = function (app) {
var requirejs = require("requirejs");
var path = require("path");
requirejs.config({
baseUrl: path.join(app.config.paths.root, "public/js")
});
app.require_public = requirejs;
// position 1
}
modules.exports = function (app) {
// position 2
var Visit = app.require_public('models/Visit');
console.log("Visit", Visit);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment