Skip to content

Commit

Permalink
adds warning and purpose
Browse files Browse the repository at this point in the history
  • Loading branch information
supershabam committed May 29, 2012
1 parent 40fb5ba commit e4d4b05
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ 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 Ready for inheritance, 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
```javascript
var Ready = require('ready')
Expand Down Expand Up @@ -34,4 +42,10 @@ myClass.ready(true);
myClass.ready(function() {
console.log('I came late to the party, but I want to execute too!');
});

// Ok, you can set the ready state to false now as well... for whatever reason
myClass.ready(false);
myClass.ready(function() {
console.log('I will not fire until you set ready to true again');
});
```

0 comments on commit e4d4b05

Please sign in to comment.