Skip to content

Instantly share code, notes, and snippets.

@TheLarkInn
Created April 24, 2016 15:03
Show Gist options
  • Save TheLarkInn/81083e4cd60265b46ec2dbca7c8c945a to your computer and use it in GitHub Desktop.
Save TheLarkInn/81083e4cd60265b46ec2dbca7c8c945a to your computer and use it in GitHub Desktop.
An empty EventManagerPlugin extension, accompanied by the EventManagerPlugins definition file so we can see how to implement it.
import { OpaqueToken } from 'angular2/src/core/di';
import { NgZone } from 'angular2/src/core/zone/ng_zone';
export declare const EVENT_MANAGER_PLUGINS: OpaqueToken;
export declare class EventManager {
private _zone;
private _plugins;
constructor(plugins: EventManagerPlugin[], _zone: NgZone);
addEventListener(element: HTMLElement, eventName: string, handler: Function): Function;
addGlobalEventListener(target: string, eventName: string, handler: Function): Function;
getZone(): NgZone;
}
export declare class EventManagerPlugin {
manager: EventManager;
supports(eventName: string): boolean;
addEventListener(element: HTMLElement, eventName: string, handler: Function): Function;
addGlobalEventListener(element: string, eventName: string, handler: Function): Function;
}
import {EventManagerPlugin} from 'angular2/platform/common_dom';
import {Injectable} from 'angular2/core';
@Injectable()
export class MultiEventPlugin extends EventManagerPlugin {
supports(eventName: string): boolean {
}
addEventListener(element: HTMLElement, eventName: string, handler: Function): Function {
}
addGlobalEventListener(target: string, eventName: string, handler: Function): Function {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment