EventManager
Yesterday I was talking about how my attempts at creating a event manager had failed.
Since the differences and problems associated with W3C DOM2 Event spec and the Microsoft events model, I decided to create an event manager based on the the old, traditional model of obj.event = func. And it works pretty good! I’m really quite proud of it
Take a look at it HERE.
Basically it just makes adding and removing listeners easy. If there is more then one listener on an event, it creates a closure so they can still all work together. All the listeners are added to a ‘registry’ so removing them is really easy, it just have to regenerate the closure without a particular listener.
[code lang="javascript"]Events.add(buttonElm, ‘click’, sayHello);
Events.add(buttonElm, ‘click’, sayGoodbye);
Events.remove(buttonElm, ‘click’, sayHello);[/code]
Just some more testing to do ![]()