Methods
emit
- emit<K>(name: K, ...data: Parameters<T[K]>): boolean
Type parameters
K: string | number | symbol
Parameters
name: K
Rest ...data: Parameters<T[K]>
Returns boolean
hasListener
- hasListener(name: keyof T): boolean
Parameters
Returns boolean
off
- off<K>(name?: K, callback?: (...args: Parameters<T[K]>) => ReturnType<T[K]>): void
Type parameters
K: string | number | symbol
Parameters
Optional name: K
Optional callback: (...args: Parameters<T[K]>) => ReturnType<T[K]>
- (...args: Parameters<T[K]>): ReturnType<T[K]>
Parameters
Rest ...args: Parameters<T[K]>
Returns ReturnType<T[K]>
Returns void
on
- on<K>(name: K, callback: (...args: Parameters<T[K]>) => ReturnType<T[K]>, once?: boolean): () => void
Type parameters
K: string | number | symbol
Parameters
name: K
callback: (...args: Parameters<T[K]>) => ReturnType<T[K]>
- (...args: Parameters<T[K]>): ReturnType<T[K]>
Parameters
Rest ...args: Parameters<T[K]>
Returns ReturnType<T[K]>
Optional once: boolean
Returns () => void
once
- once<K>(name: K, callback: (...args: Parameters<T[K]>) => ReturnType<T[K]>): () => void
Type parameters
K: string | number | symbol
Parameters
name: K
callback: (...args: Parameters<T[K]>) => ReturnType<T[K]>
- (...args: Parameters<T[K]>): ReturnType<T[K]>
Parameters
Rest ...args: Parameters<T[K]>
Returns ReturnType<T[K]>
Returns () => void
监听者模式