I have a namespace setup like this:
var myApp = {};
(function(context) {
var id = 0;
context.next = function() {
return id++;
};
context.reset = function() {
id = 0;
}
})(myApp);
window.console && console.log(
myApp.next(),
myApp.next(),
myApp.reset(),
myApp.next()
) //0, 1, undefined, 0
I now want to to have a callback from myApp which i can catch outside of the namespace..
Any ideas how to set that up with my namespace setup?
For example something like this:
myApp.setCallback('next', function() {
alert('hello');
});