import{IEventEmitter,EventEmitter,IEmitterSubscriber}from"observer-pattern-js";constemitter: IEventEmitter=newEventEmitter();constsubscriber: IEmitterSubscriber=emitter.subscribe('event-name',(name,surname,age): void=>{console.log(name);// Ikrom.console.log(surname);// Murodov.console.log(age);// 18.},);emitter.emit('event-name','Ikrom','Murodov',18);// If you want to unsubscribe from an event you can call the unsubscribe method.subscriber.unsubscribe();
EventEmitter (API).
subscribe - Adds the listener function to the end of the listeners array for the event named eventName.
Adds the listener function to the end of the listeners array for the event named eventName.
@param { string } eventName - name of events to subscribe.