vendredi 27 février 2015

With Facebook's EventEmitter is there a way to make a late listener receive an event thats already been emitted?

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):



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.


Aucun commentaire:

Enregistrer un commentaire