For example
var event = {
    message: function(message){console.log(message);}
}
//polling here
{
    if(response.type == "message")
    {
        event[response.type](response.message);
    }
}
should work similarly to
events.on("message", function(message){console.log(message);});
//polling here
{
    events.emit(response.type, response.message);
}
If not, how is it different to EventEmitter other than auxiliary functions like .once?
I'm using both at the same time for different reasons. EventEmitter is for event-driven functions while the event object is for keeping an organized set of functions to trigger from a single context (event).
via Vic
 
No comments:
Post a Comment