Canceled account
Sat, 27 Sep 2014 09:44:28 GMT
Hi all. In my particular application the Admin object initialisation happens instantly and because of this, the `instance.on("ready", function() {})` part has no effect.
What would be the idiomatic way to make sure the callback is always executed, regardless of the speed of Admin object initialisation? Currently I'm passing a second argument to Admin, an onReady function, instead of using the `"ready"` event binding, and I'm calling it when done initialising the object. Is it the right way to do this?
The original code:
---
// configuration argument --> start the application
} else {
instance = new Admin(arg);
instance.on("ready", function() {
admin.trigger("ready", instance);
});
}
---
My version:
---
function Admin(conf, onReady) {
// ... init stuff
// signal readiness
onReady();
}
// configuration argument --> start the application
} else {
instance = new Admin(arg, function() {
admin.trigger("ready", instance);
});
}
---