material-motion / material-motion-js

Reusable gestural interactions in JavaScript. In development.
Apache License 2.0
290 stars 26 forks source link

Explore inferring getEventStreamFromElement's generic with overrides #245

Open appsforartists opened 6 years ago

appsforartists commented 6 years ago

It probably looks something like this:

export function getEventStreamFromElement<U extends Event = Event>(type: string, element: Element, eventListenerOptions?: AddEventListenerOptions): ObservableWithMotionOperators<U>;
export function getEventStreamFromElement<K extends keyof GlobalEventHandlersEventMap>(type: K, element: Element, eventListenerOptions?: AddEventListenerOptions): ObservableWithMotionOperators<GlobalEventHandlersEventMap[K]>;
davidkpiano commented 6 years ago

It's alive!