Created
January 13, 2012 19:31
-
-
Save jrburke/1608271 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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