If I have an object thats fetching data and it emits a "ready" event but another object starts listening for that event after it has already been fired is there a direct way of allowing that listener to receive that missed event.
Purely hypothetical example (so please don't ask why I would do this):
function DataModule(){
this.data = null;
request.get( 'http://example.com/api/get/data', function( error, response, body ) {
if ( ! err ) {
this.data = body;
this.emit( 'ready' );
}
}.bind( this ) );
}
...
var dataModule = new DataModule(); // data fetching happens here.
setTimeout( function(){
dataModule.once( 'ready', function(){
// Perform some action when the data is ready
} );
}, 5000 ); // Five second delay
In the above example lets assume that DataModule
fetches it's data asynchronously and its really quick.