Files
socket.io/lib/on.ts
Damien Arrachequesne 91b948b860 refactor: move the typed events to @socket.io/component-emitter
The typed events have been moved to [1] in order to remove the
intermediary class and reduce the bundle size.

Diff: https://github.com/socketio/emitter/compare/2.0.0...3.0.0

[1]: https://github.com/socketio/emitter/
2021-10-14 14:09:23 +02:00

13 lines
245 B
TypeScript

import { Emitter } from "@socket.io/component-emitter";
export function on(
obj: Emitter<any, any>,
ev: string,
fn: (err?: any) => any
): VoidFunction {
obj.on(ev, fn);
return function subDestroy(): void {
obj.off(ev, fn);
};
}