Created
April 24, 2016 14:52
-
-
Save TheLarkInn/2fd731742536444f4d2a92e3ef0b7bfa to your computer and use it in GitHub Desktop.
A closer look at event_managers method for searching though its plugins to find valid eventplugins using the implemented supports() function.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
addEventListener(element: HTMLElement, eventName: string, handler: Function): Function { | |
var plugin = this._findPluginFor(eventName); | |
return plugin.addEventListener(element, eventName, handler); | |
} | |
addGlobalEventListener(target: string, eventName: string, handler: Function): Function { | |
var plugin = this._findPluginFor(eventName); | |
return plugin.addGlobalEventListener(target, eventName, handler); | |
} | |
getZone(): NgZone { return this._zone; } | |
/** @internal */ | |
_findPluginFor(eventName: string): EventManagerPlugin { | |
var plugins = this._plugins; | |
for (var i = 0; i < plugins.length; i++) { | |
var plugin = plugins[i]; | |
if (plugin.supports(eventName)) { | |
return plugin; | |
} | |
} | |
throw new BaseException(`No event manager plugin found for event ${eventName}`); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment