src/vs/base/browser/dom.ts/createEventEmitter
export function createEventEmitter<K extends keyof HTMLElementEventMap>(target: HTMLElement, type: K, options?: boolean | AddEventListenerOptions): event.Emitter<HTMLElementEventMap[K]> {
	let domListener: DomListener | null = null;
	const handler = (e: HTMLElementEventMap[K]) => result.fire(e);
	const onFirstListenerAdd = () => {
		if (!domListener) {
			domListener = new DomListener(target, type, handler, options);
		}
	};
	const onLastListenerRemove = () => {
		if (domListener) {
			domListener.dispose();
			domListener = null;
		}
	};
	const result = new event.Emitter<HTMLElementEventMap[K]>({ onFirstListenerAdd, onLastListenerRemove });
	return result;
}