{"_id":"@ayu-sh-kr/dota-event","_rev":"5-1a4f77368bc55176e1c6e1c5c6548bc8","name":"@ayu-sh-kr/dota-event","dist-tags":{"latest":"0.0.5"},"versions":{"0.0.1":{"name":"@ayu-sh-kr/dota-event","version":"0.0.1","keywords":["Dota Core Plugins","Web Components"],"author":{"url":"https://linkedin.com/in/ayu-sh-kr","name":"ayu-sh-kr","email":"akjaiswal2003@gmail.com"},"license":"MIT","_id":"@ayu-sh-kr/dota-event@0.0.1","maintainers":[{"name":"ayu-sh-kr","email":"akjaiswal2003@gmail.com"}],"dist":{"shasum":"10084249e67aa204818d267988216e33c73a83cd","tarball":"https://registry.npmjs.org/@ayu-sh-kr/dota-event/-/dota-event-0.0.1.tgz","fileCount":6,"integrity":"sha512-hZNq8igY3oGJIfOnKvEpw9wfWvFUNzpUa7rDBNvOhUEQWukdjtKu2TYjIq/sIUeG3G7DKe81lxqPcTb/m+79CA==","signatures":[{"sig":"MEUCIQDQ/ZDZDlVReXgK0Ok6nKiyHXBtXdHmc5G+t+uI3ZOAYgIgVobiYUks7bUQDaQGixerM+VN70Cs/BkRs1K1tvpyf90=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":41544},"main":"./dist/index.js","type":"module","_from":"file:ayu-sh-kr-dota-event-0.0.1.tgz","types":"./dist/index.d.ts","module":"./dist/index.mjs","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","module":"./dist/index.mjs","default":"./dist/index.js","require":"./dist/index.js"}},"private":false,"scripts":{"dev":"vite","test":"vitest run","build":"tsc && vite build","preview":"vite preview","release":"pnpm run build && changeset publish","test:watch":"vitest","test:coverage":"vitest run --coverage"},"_npmUser":{"name":"ayu-sh-kr","email":"akjaiswal2003@gmail.com"},"_resolved":"/tmp/afde342b772bbb2e80220e5441309c95/ayu-sh-kr-dota-event-0.0.1.tgz","_integrity":"sha512-hZNq8igY3oGJIfOnKvEpw9wfWvFUNzpUa7rDBNvOhUEQWukdjtKu2TYjIq/sIUeG3G7DKe81lxqPcTb/m+79CA==","_npmVersion":"11.9.0","description":"dota-event is a library that provides api for event-driven programming in dota ecosystem.","directories":{},"_nodeVersion":"25.6.1","dependencies":{"reflect-metadata":"^0.2.2"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/dota-event_0.0.1_1771434988460_0.8153616414791252","host":"s3://npm-registry-packages-npm-production"}},"0.0.2":{"name":"@ayu-sh-kr/dota-event","version":"0.0.2","keywords":["Dota Core Plugins","Web Components"],"author":{"url":"https://linkedin.com/in/ayu-sh-kr","name":"ayu-sh-kr","email":"akjaiswal2003@gmail.com"},"license":"MIT","_id":"@ayu-sh-kr/dota-event@0.0.2","maintainers":[{"name":"ayu-sh-kr","email":"akjaiswal2003@gmail.com"}],"dist":{"shasum":"17381ddc20156fc018f8d5f5f3eb3de2ed67ee27","tarball":"https://registry.npmjs.org/@ayu-sh-kr/dota-event/-/dota-event-0.0.2.tgz","fileCount":6,"integrity":"sha512-ArnpMUdYyHiWkri5DmZfhEyppHAjhnr/NERyGxctZhmmVvq+URJU4et1SkXifD0TPNM0aGtQTtYxAr6S6SRDEQ==","signatures":[{"sig":"MEUCIDOjohFy7BGEBvwjRbYj+V7rWcf/atUsIXwffIS0XEsvAiEAkpz5/Aa6+p+PCpe+j8gbs5c6iDoiUjK3qKjEqYgOzcw=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":48876},"main":"./dist/index.js","type":"module","_from":"file:ayu-sh-kr-dota-event-0.0.2.tgz","types":"./dist/index.d.ts","module":"./dist/index.mjs","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","module":"./dist/index.mjs","default":"./dist/index.js","require":"./dist/index.js"}},"private":false,"scripts":{"dev":"vite","test":"vitest run","build":"tsc && vite build","preview":"vite preview","release":"pnpm run build && changeset publish","test:watch":"vitest","test:coverage":"vitest run --coverage"},"_npmUser":{"name":"ayu-sh-kr","email":"akjaiswal2003@gmail.com"},"_resolved":"/tmp/3bc9b4e0c861380e3cf60b9509ed23ee/ayu-sh-kr-dota-event-0.0.2.tgz","_integrity":"sha512-ArnpMUdYyHiWkri5DmZfhEyppHAjhnr/NERyGxctZhmmVvq+URJU4et1SkXifD0TPNM0aGtQTtYxAr6S6SRDEQ==","_npmVersion":"11.9.0","description":"dota-event is a library that provides api for event-driven programming in dota ecosystem.","directories":{},"_nodeVersion":"25.6.1","dependencies":{"reflect-metadata":"^0.2.2"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/dota-event_0.0.2_1771439381539_0.708177670499414","host":"s3://npm-registry-packages-npm-production"}},"0.0.3":{"name":"@ayu-sh-kr/dota-event","version":"0.0.3","keywords":["Dota Core Plugins","Web Components"],"author":{"url":"https://linkedin.com/in/ayu-sh-kr","name":"ayu-sh-kr","email":"akjaiswal2003@gmail.com"},"license":"MIT","_id":"@ayu-sh-kr/dota-event@0.0.3","maintainers":[{"name":"ayu-sh-kr","email":"akjaiswal2003@gmail.com"}],"dist":{"shasum":"256ad1ce0af2d49c9820be5c958dfbcdad8ee0ec","tarball":"https://registry.npmjs.org/@ayu-sh-kr/dota-event/-/dota-event-0.0.3.tgz","fileCount":6,"integrity":"sha512-OLZmRN02RwtIGh7yaRFowi3Dm6FVbVH0oKOFSzopjZ6xIMuWvDq0FLGj8Xnuff2UAa+e1KZodt6hSOyep1TJHA==","signatures":[{"sig":"MEYCIQDWxyH1GwxiFn2Tq952uEkmRg0lfN6k/r3J+sjFDBI6zAIhAJd4fH89ogO7djkik0YSsHh3YjCsKTI6pt91BgQ0+uWf","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":68133},"main":"./dist/index.js","type":"module","_from":"file:ayu-sh-kr-dota-event-0.0.3.tgz","types":"./dist/index.d.ts","module":"./dist/index.mjs","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","module":"./dist/index.mjs","default":"./dist/index.js","require":"./dist/index.js"}},"private":false,"scripts":{"dev":"vite","test":"vitest run","build":"tsc && vite build","preview":"vite preview","release":"pnpm run build && changeset publish","test:watch":"vitest","test:coverage":"vitest run --coverage"},"_npmUser":{"name":"ayu-sh-kr","email":"akjaiswal2003@gmail.com"},"_resolved":"/tmp/2ca2d9d36208f60c067f3cc649d34715/ayu-sh-kr-dota-event-0.0.3.tgz","_integrity":"sha512-OLZmRN02RwtIGh7yaRFowi3Dm6FVbVH0oKOFSzopjZ6xIMuWvDq0FLGj8Xnuff2UAa+e1KZodt6hSOyep1TJHA==","_npmVersion":"11.9.0","description":"dota-event is a library that provides api for event-driven programming in dota ecosystem.","directories":{},"_nodeVersion":"25.6.1","dependencies":{"reflect-metadata":"^0.2.2"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/dota-event_0.0.3_1771679844446_0.3673338201681515","host":"s3://npm-registry-packages-npm-production"}},"0.0.4":{"name":"@ayu-sh-kr/dota-event","version":"0.0.4","keywords":["Dota Core Plugins","Web Components"],"author":{"url":"https://linkedin.com/in/ayu-sh-kr","name":"ayu-sh-kr","email":"akjaiswal2003@gmail.com"},"license":"MIT","_id":"@ayu-sh-kr/dota-event@0.0.4","maintainers":[{"name":"ayu-sh-kr","email":"akjaiswal2003@gmail.com"}],"dist":{"shasum":"18a525eea9d8314032e0255d337981a034d8cf32","tarball":"https://registry.npmjs.org/@ayu-sh-kr/dota-event/-/dota-event-0.0.4.tgz","fileCount":6,"integrity":"sha512-nlN0+TMCWA3PIBhx/NAqQ50srynZ/5vKmz8lZSPOjgpo4bTW+nBIP4jw/QQL8shvrI5qqxgi1ZH3m03GyDqJ9A==","signatures":[{"sig":"MEUCIQDfQEqku8v1cIY1mLpbXOZo0P1XWMk73tfE9PJBrjgyoAIgWScRPVXkh7kYU/GWIDrd/McnjK2pJYQr4TIX/GfaGR8=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":84408},"main":"./dist/index.js","type":"module","_from":"file:ayu-sh-kr-dota-event-0.0.4.tgz","types":"./dist/index.d.ts","module":"./dist/index.mjs","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","module":"./dist/index.mjs","default":"./dist/index.js","require":"./dist/index.js"}},"private":false,"scripts":{"dev":"vite","test":"vitest run","build":"tsc && vite build","preview":"vite preview","release":"pnpm run build && changeset publish","test:watch":"vitest","test:coverage":"vitest run --coverage"},"_npmUser":{"name":"ayu-sh-kr","email":"akjaiswal2003@gmail.com"},"_resolved":"/tmp/a6a7cbfea53ae51a5420b77f1aac97d6/ayu-sh-kr-dota-event-0.0.4.tgz","_integrity":"sha512-nlN0+TMCWA3PIBhx/NAqQ50srynZ/5vKmz8lZSPOjgpo4bTW+nBIP4jw/QQL8shvrI5qqxgi1ZH3m03GyDqJ9A==","_npmVersion":"11.9.0","description":"dota-event is a library that provides api for event-driven programming in dota ecosystem.","directories":{},"_nodeVersion":"25.6.1","dependencies":{"reflect-metadata":"^0.2.2"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/dota-event_0.0.4_1771866113066_0.8396842045733326","host":"s3://npm-registry-packages-npm-production"}},"0.0.5":{"name":"@ayu-sh-kr/dota-event","private":false,"publishConfig":{"access":"public"},"version":"0.0.5","description":"dota-event is a library that provides api for event-driven programming in dota ecosystem.","author":{"name":"ayu-sh-kr","email":"akjaiswal2003@gmail.com","url":"https://linkedin.com/in/ayu-sh-kr"},"license":"MIT","keywords":["Dota Core Plugins","Web Components"],"type":"module","types":"./dist/index.d.ts","main":"./dist/index.js","module":"./dist/index.mjs","exports":{".":{"types":"./dist/index.d.ts","module":"./dist/index.mjs","import":"./dist/index.mjs","require":"./dist/index.js","default":"./dist/index.js"}},"dependencies":{"reflect-metadata":"^0.2.2"},"scripts":{"dev":"vite","build":"tsc && vite build","preview":"vite preview","release":"pnpm run build && changeset publish","test":"vitest run","test:watch":"vitest","test:coverage":"vitest run --coverage"},"_id":"@ayu-sh-kr/dota-event@0.0.5","_integrity":"sha512-1p7PNrFfd5bU+sMIGcbO2vmmB7bx4GxVvlPl35flPuPZwSIAmV51aqXStFp2Kw7T/DD6vJ3ObixGe+YY2XzvBQ==","_resolved":"/tmp/a19d08612257b190d6eb441dc7a6b52b/ayu-sh-kr-dota-event-0.0.5.tgz","_from":"file:ayu-sh-kr-dota-event-0.0.5.tgz","_nodeVersion":"25.7.0","_npmVersion":"11.10.1","dist":{"integrity":"sha512-1p7PNrFfd5bU+sMIGcbO2vmmB7bx4GxVvlPl35flPuPZwSIAmV51aqXStFp2Kw7T/DD6vJ3ObixGe+YY2XzvBQ==","shasum":"4c57b3d475b661b7cd51132d0001367a1a53787f","tarball":"https://registry.npmjs.org/@ayu-sh-kr/dota-event/-/dota-event-0.0.5.tgz","fileCount":6,"unpackedSize":83127,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCNtfTSX8nW+1TujbL00KImSW0x2FkS3hTSf9inALBv3QIhALsly8LW+51RbTXPw2HyVgKwOSacycvMhS2O/ZTHNvvd"}]},"_npmUser":{"name":"ayu-sh-kr","email":"akjaiswal2003@gmail.com"},"directories":{},"maintainers":[{"name":"ayu-sh-kr","email":"akjaiswal2003@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/dota-event_0.0.5_1772296547616_0.6230625554059803"},"_hasShrinkwrap":false}},"time":{"created":"2026-02-18T17:16:28.315Z","modified":"2026-02-28T16:35:47.888Z","0.0.1":"2026-02-18T17:16:28.608Z","0.0.2":"2026-02-18T18:29:41.712Z","0.0.3":"2026-02-21T13:17:24.599Z","0.0.4":"2026-02-23T17:01:53.211Z","0.0.5":"2026-02-28T16:35:47.770Z"},"author":{"name":"ayu-sh-kr","email":"akjaiswal2003@gmail.com","url":"https://linkedin.com/in/ayu-sh-kr"},"license":"MIT","keywords":["Dota Core Plugins","Web Components"],"description":"dota-event is a library that provides api for event-driven programming in dota ecosystem.","maintainers":[{"name":"ayu-sh-kr","email":"akjaiswal2003@gmail.com"}],"readme":"# dota-event\n\nLightweight application event primitives used across the monorepo.\n\nThis package provides a small publish/subscribe event system and a decorator-based way to bind instance methods as event handlers. It's designed to be simple and easy to use in both apps and libraries inside the workspace.\n\n## Features\n\n- A small `ApplicationEvent` type and handler callback signature.\n- `DefaultApplicationEventManager` — a Map/Set-backed manager for event handler storage.\n- `DefaultApplicationEventBus` — a singleton event bus (lazy) used to register, unregister and emit events.\n- `DefaultApplicationEventPublisher` / `DefaultApplicationEventListener` — lightweight facades for publishing and listening.\n- `@OnEvent` decorator and helpers to bind/unbind decorated instance methods to a listener.\n\n## Installation\n\nIn this monorepo you can import the package locally. For external usage (when published) replace the import path with the published package name.\n\nUsing pnpm (from repo root):\n\npnpm add @ayu-sh-kr/dota-event\n\nOr (monorepo/local) import directly from the package path in your TypeScript project.\n\n> Note: the examples below use the package-style import path `@ayu-sh-kr/dota-event`. Replace it with your local/monorepo path if necessary.\n\n## Requirements\n\n- TypeScript\n- reflect-metadata (used by the `@OnEvent` decorator)\n- If using decorators, enable `experimentalDecorators` and `emitDecoratorMetadata` in your `tsconfig.json`.\n\nInstall reflect-metadata if you plan to use the decorator helpers:\n\npnpm add reflect-metadata\n\nand import it once (for example in your app entry):\n\nimport 'reflect-metadata';\n\n## Quick API summary\n\nExports you will typically use:\n\n- Types\n  - `ApplicationEvent` — { name: string; data?: any }\n  - `ApplicationEventCallback` — (event: ApplicationEvent) => void\n\n- Manager\n  - `DefaultApplicationEventManager` — add/remove/resolve/clear\n\n- Bus\n  - `DefaultApplicationEventBus` — singleton via `DefaultApplicationEventBus.getInstance()`\n    - Note: the bus class implements its `on`, `off`, and `emit` methods as async (`Promise<void>`), so you can `await` those calls. (The public `Types` interface is minimal; prefer checking the class behavior in code.)\n\n- Facades\n  - `DefaultApplicationEventPublisher` — `publish(event: ApplicationEvent): void` and `publishAsync(event): Promise<void>`\n  - `DefaultApplicationEventListener` — `on(event, callback)` and `off(event, callback)` (delegates to the bus)\n\n- Decorator & helpers (from `on-event.decorator.ts`)\n  - `OnEvent(name: string)` — method decorator\n  - `getOnEventMetadata(targetOrInstance)` — read metadata\n  - `bindInstanceEventHandlers(instance, listener)` — register decorated methods on a listener\n  - `unbindInstanceEventHandlers(instance, listener)` — unregister decorated methods from a listener\n\n## DefaultClassApplicationEventBindManager\n\n`DefaultClassApplicationEventBindManager` is the package's class-level helper for managing decorated instance method bindings on a provided `ApplicationEventListener`. It:\n\n- Scans a target instance's `@OnEvent` metadata and binds each method to the listener.\n- Keeps an internal store of bound callbacks organized by event name and method key.\n- Prevents duplicate registrations: calling `bind()` multiple times will not re-register the same method for the same event because the manager checks the internal store before adding a listener.\n- Ensures precise unbinding: `unbind()` uses the stored bound callback references to remove the exact functions from the listener and cleans up empty entries.\n\nThis makes it safe for services or components that might initialize or call `bind()` repeatedly (for example during hot-reload or multiple init attempts) without producing duplicate listener invocations.\n\n## Quickstart examples\n\nAll snippets are TypeScript and assume the following import path — replace with your project-specific path if needed:\n\nimport {\n  DefaultApplicationEventBus,\n  DefaultApplicationEventPublisher,\n  DefaultApplicationEventListener,\n  OnEvent,\n  bindInstanceEventHandlers,\n  unbindInstanceEventHandlers,\n  ApplicationEvent\n} from '@ayu-sh-kr/dota-event';\n\n### 1) Basic singleton bus (on / emit / off)\n\n```ts\n// get the shared bus\nconst bus = DefaultApplicationEventBus.getInstance();\n\n// register a handler (bus.on is async)\nawait bus.on('user:created', (event) => {\n  console.log('user created:', event.data);\n});\n\n// emit an event (emit is async)\nawait bus.emit({ name: 'user:created', data: { id: 1, name: 'alice' } });\n\n// remove all handlers for an event\nawait bus.off('user:created', null);\n```\n\n### 2) Using the publisher / publishAsync\n\n```ts\nconst bus = DefaultApplicationEventBus.getInstance();\nconst publisher = new DefaultApplicationEventPublisher(bus);\n\n// publish synchronously (note: the implementation delegates to the bus emit but the method itself is synchronous)\npublisher.publish({ name: 'order:placed', data: { id: 42 } });\n\n// publish asynchronously and await handlers\nawait publisher.publishAsync({ name: 'order:placed', data: { id: 43 } });\n```\n\n> Note: `publish` calls the bus `emit` but does not await it; use `publishAsync` when you need to wait for handlers.\n\n### 3) Decorator-based handlers (class methods)\n\n```ts\nimport 'reflect-metadata'; // ensure this is imported somewhere in your app\n\nclass MyService {\n  @OnEvent('payment:received')\n  onPayment(event: ApplicationEvent) {\n    console.log('payment received', event.data);\n  }\n}\n\nconst instance = new MyService();\nconst bus = DefaultApplicationEventBus.getInstance();\nconst listener = new DefaultApplicationEventListener(bus);\n\n// register all decorated handlers from instance onto the listener\nawait bindInstanceEventHandlers(instance, listener);\n\n// publish — handlers bound above will run\nawait bus.emit({ name: 'payment:received', data: { amount: 100 } });\n\n// when shutting down or removing the instance\nawait unbindInstanceEventHandlers(instance, listener);\n```\n\n### 4) Advanced: multiple handlers and clearing\n\n```ts\nconst bus = DefaultApplicationEventBus.getInstance();\n\nawait bus.on('metrics:tick', () => console.log('handler A'));\nawait bus.on('metrics:tick', () => console.log('handler B'));\n\nawait bus.emit({ name: 'metrics:tick' });\n// -> handler A\n// -> handler B\n\n// Remove all handlers for the event\nawait bus.off('metrics:tick', null);\n```","readmeFilename":"README.md"}