While developing in javascript, I spent tons time to figure out what arguments are passed among functions. So I tried a new method today. I created a simple object then define event name and arguments.
var GreetingEvent = {
HELLO: 'hello',
'arguments': {
name: null
}
}
// dispatch
// pseudo code
this.fireEvent( new MyEvent(GreetingEvent.HELLO,"myname") );
// listening
// pseudo code
this.listenToEvent(GreetingEvent.HELLO, this.onGreetingEvent);
I'm sure that others already experienced my situation.
What was your situation and solution?
Update:
this is how I'm coding now.
// dispatch
// pseudo code
this.fireEvent('hello',{name:'myname'});
// listening
// pseudo code
this.listenToEvent('hello', this.onGreetingEvent);
the problem of this code is that my co-workers must open my code to find out what arguments are being passed to their listeners or they have to use console.log(). That's actually fine. I'm just trying to find a better way.