Okay, you twisted my arm, here is all the relevant:

class EventHandler:
    def __init__(self):
        self._events = {}

    def addEventType(self, event):
        if event in self._events.keys():
            raise KeyError(event+" already exists.")
        self._events[event] = []

    def getSubscribers(self, event):
        return self._events[event]

    def subscribe(self, event, subscriber):
        self._events[event].append(subscriber)

    def unsubscribe(self, event, subscriber):
        self._events[event].remove(subscriber)

    def notify(self, event, data):
        for sub in self._events[event]:
            sub(data)

On Tue, Nov 29, 2011 at 11:37 AM, Luke Kenneth Casson Leighton
<[email protected]> wrote:
> On Tue, Nov 29, 2011 at 4:33 PM, Lex Berezhny <[email protected]> wrote:
>> EventHandler, addEventType() and notify() are not part of pyjamas
>> (it's a custom framework i've built) so you will substitute whatever
>> you want there, but TextBox and addKeyboardListener() is part of
>> pyajamas.
>
>  that wouldn't happen to be virtually identical to the event handler
> code that i wrote, and made part of pyjamas, would it?
>
>  or... it wouldn't happen to be virtually identical to the event
> handler code that rich wrote, and i poked and prodded him to put it
> into pyjamas?
>
>  :)
>

Reply via email to