I fully understand why EventController was written the way it was, it's a general purpose framework and having variable arguments is useful. In my case I prefer not having any method name munging or extra checks for different usage patterns or any need currently for variable number of arguments.
I don't think it's worth debating over 30 lines of Python code. Another twenty lines and I can easily add most of the missing features like variable arguments, etc. Another advantage to having my own EventHandler is that I can experiment with different ways of doing things without worrying about changing the official version that other people may be depending on. - lex On Tue, Nov 29, 2011 at 12:26 PM, Luke Kenneth Casson Leighton <[email protected]> wrote: > On Tue, Nov 29, 2011 at 5:05 PM, Lex Berezhny <[email protected]> wrote: >> The EventController is significantly more complicated. > > no it's not! > >> And I don't >> really gain anything at all from the complexity. Mine is very simple >> and does exactly what I want with very minimal setup. > > the setup on use of Handler is actually less than what you would be > forced to use in the code that you've written. > > from pyjamas.EventController import Handler > > h = Handler("login") > > h.addListener(login_callback_object) > > # trigger: > h.onLoginEvent() > > class LoginCallbackObject: > def onLoginEvent(self, sender): > print "called", sender > > > whereas with what you have, it has to be: > > h = Handler() > h.addEventType("login") > h.subscribe("login", login_callback_object) > > # trigger: > h.notify("login", None) # forced requirement to have data not *args > > > ... you see the difference? in the next N months, i guarantee that > you'll go "hmm, i remember that event code, i could use it here but > whoops, i now have to make it quotes complicated quotes because oh > dear it doesn't take enough arguments or it's getting quotes > complicated quotes because i have to call notify with so many > different string arguments because it's being used for so many > different purposes" > > one to watch out for. > > l. >

