Skip to content

Instantly share code, notes, and snippets.

@jrburke
Created January 13, 2012 19:31
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jrburke/1608271 to your computer and use it in GitHub Desktop.
Save jrburke/1608271 to your computer and use it in GitHub Desktop.
var FakeAPI = (function(){
var api = {
add: null,
addWithCallback: null
}
function makeMethod(method) {
return function() {
var context = this;
var args = arguments;
console.log('args outside of require ', args);
require(['real_api'], function(real_api){
console.log('args inside of require ', args); // notice callback functions are missing from args now
return real_api[method].apply(context, args);
});
}
}
for( method in api ) {
api[method] = makeMethod(method);
}
return api;
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment