main
Last change
on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
937 bytes
|
Line | |
---|
1 | export interface ListenerType1 {
|
---|
2 | addEventListener(name: string, handler: (event?: any) => void, ...args: any[]): any;
|
---|
3 | removeEventListener(name: string, handler: (event?: any) => void, ...args: any[]): any;
|
---|
4 | }
|
---|
5 | export interface ListenerType2 {
|
---|
6 | on(name: string, handler: (event?: any) => void, ...args: any[]): any;
|
---|
7 | off(name: string, handler: (event?: any) => void, ...args: any[]): any;
|
---|
8 | }
|
---|
9 | export declare type UseEventTarget = ListenerType1 | ListenerType2;
|
---|
10 | declare type AddEventListener<T> = T extends ListenerType1 ? T['addEventListener'] : T extends ListenerType2 ? T['on'] : never;
|
---|
11 | export declare type UseEventOptions<T> = Parameters<AddEventListener<T>>[2];
|
---|
12 | declare const useEvent: <T extends UseEventTarget>(name: Parameters<AddEventListener<T>>[0], handler?: Parameters<AddEventListener<T>>[1] | null | undefined, target?: Window | T | null, options?: UseEventOptions<T> | undefined) => void;
|
---|
13 | export default useEvent;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.