{ "version": 3, "sources": ["../../Scripts/EventDispatcher.ts"], "sourcesContent": ["\uFEFFexport type EventHandler<E> = (event: E) => void;\n\nexport interface Event<E> {\n register(handler: EventHandler<E>): void;\n unregister(handler: EventHandler<E>): void;\n}\n\nexport class EventDispatcher<E> implements Event<E> {\n\n private readonly _handlers: EventHandler<E>[];\n\n constructor() {\n this._handlers = [];\n }\n\n public register(handler: EventHandler<E>): void {\n this._handlers.push(handler);\n }\n \n public unregister(handler: EventHandler<E>): void {\n for (let i = 0; i < this._handlers.length; i++) {\n if (this._handlers[i] === handler) {\n this._handlers.splice(i, 1);\n }\n }\n }\n\n public dispatch(event: E): void {\n for (const handler of this._handlers) {\n handler(event);\n }\n }\n}"], "mappings": ";AAOO,IAAM,kBAAN,MAA6C;AAAA,EAIhD,cAAc;AACV,SAAK,YAAY,CAAC;AAAA,EACtB;AAAA,EAEO,SAAS,SAAgC;AAC5C,SAAK,UAAU,KAAK,OAAO;AAAA,EAC/B;AAAA,EAEO,WAAW,SAAgC;AAC9C,aAAS,IAAI,GAAG,IAAI,KAAK,UAAU,QAAQ,KAAK;AAC5C,UAAI,KAAK,UAAU,CAAC,MAAM,SAAS;AAC/B,aAAK,UAAU,OAAO,GAAG,CAAC;AAAA,MAC9B;AAAA,IACJ;AAAA,EACJ;AAAA,EAEO,SAAS,OAAgB;AAC5B,eAAW,WAAW,KAAK,WAAW;AAClC,cAAQ,KAAK;AAAA,IACjB;AAAA,EACJ;AACJ;", "names": [] }