Skip to content

Instantly share code, notes, and snippets.

@giangm9
Last active April 16, 2021 03:27
Show Gist options
  • Save giangm9/760ef1201fb3fae61366f1d0a2b04b13 to your computer and use it in GitHub Desktop.
Save giangm9/760ef1201fb3fae61366f1d0a2b04b13 to your computer and use it in GitHub Desktop.
export declare type EventCallback<T> = (arg: T) => any;
export declare type Event<T = any> = EventCallback<T>[];
export function emit<T>(e: Event<T>, data: T) {
e.forEach(callback => callback(data))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment