It'd be nice to have an event.type implemented into the API so that we have a little more control and flexibility on how we manage our events...
For example, event.type = SFS2X.SFSEvent.CONNECTION.
I forward my events to an observer to be handled by the application... However, as it is now, I have to create a specific function for each SFS event, modify the event object to include it's type, and then forward it to my observer.
Why isn't there an event.type?
Re: Why isn't there an event.type?
Hi,
I am not sure if I understand this correctly. Having dedicated function calls for each event is already the best way to handle events.
Using a global observer would lead to this code:
Which bring us back from where we started, with an additional passage.
I am not sure if I understand this correctly. Having dedicated function calls for each event is already the best way to handle events.
Using a global observer would lead to this code:
Code: Select all
function handler(event)
{
if(event.type == CONNECT)
handleConnect(event)
else if if(event.type == LOGIN)
handleLogin(event)
//...
}