I need help understanding this piece of code. What is the point of handler.guid
? Why is there a need for a hash table?
What is the point of:
The guid
is used to give each event a unique index, while the hash table is used to implement a dynamic dispatch table. this.$$handleEvent
refers to the element in the handler mapping table.
A callback system works by storing event handlers in an array. When the underlying event is detected the dispatch system loops through the array calling the callback functions in turn.
The jQuery Event object uses a similar structure.
References