ready
NodeJS mixin to add one-time ready event
Purpose
Events are great. You should use events, but not for signaling ready! Ready implies state, and once you are ready, you stay ready.
This is a module for everyone who has bound an event handler.on('ready', function() {}) that doesn't execute because you added the handler after the 'ready' event already fired.
Warning
If you use this mixin, you must have 'ready', '_ready', and '_readyCallbacks' available on your class. Ready will stomp on these variables if you're trying to use them in your class.
Example
var ready = ; // example class that uses Ready { thissomeProperty = 'some value';}ready; // Normal class prototype functionsMyClassprototype {}; // Create a new class that uses ready mixinvar myClass = ; // Add callback for when myClass is readymyClass; myClass; // We are now ready, fire callbacks!myClass; // Adding a new callback once we're already ready gets executed immediatelymyClass; // Ok, you can set the ready state to false now as well... for whatever reasonmyClass;myClass;