type Callback = (...args: any) => void; type Eventified = T & { on(eventName: string, callback: Callback): Eventified; off(eventName: string, callback: Callback): Eventified; emit(event: string | E, ...args: Array): Eventified; }; /** Add a simple chainable `.on()`, `.off()`, `.emit()` interface to any object. Defaults to returning a new, empty object with these methods. ### Example usage: const app = {}; eventify( app ); 1) Emit named event: app.on('foo', () => doStuff()); //... app.emit('foo'); 2) Emit event object with type as a property: app.on('foo2', (event) => doStuff(event.target)); //... app.emit({ type: 'foo2', target: targObj }); 3) Emit named event with extra parameters: app.on('bar', (some, data) => use(some.toUpperCase(), data)); //... app.emit('bar', 'whatever', someProps); 4) Emit event object (with .type prop), along with extra parameters: app.on('baz', (event, some, data) => use(event.target, some.toUpperCase(), data)); //... app.emit({ type: 'baz', target: targObj }, 'whatever', someObj); */ export default function eventify(object?: T): Eventified; export {};