{"name":"@eggjs/eventbus-decorator","version":"4.0.2-beta.5","keywords":["egg","eventbus","eventemitter","tegg","typescript"],"author":{"name":"killagu","email":"killa123@126.com"},"license":"MIT","_id":"@eggjs/eventbus-decorator@4.0.2-beta.5","maintainers":[{"name":"gxkl","email":"gxkl203@gmail.com"},{"name":"eggjs-admin","email":"fengmk2+eggjs@gmail.com"},{"name":"fengmk2","email":"fengmk2@gmail.com"},{"name":"atian25","email":"atian25@qq.com"},{"name":"hyj1991","email":"yeekwanvong@gmail.com"},{"name":"killagu","email":"killa07071201@gmail.com"},{"name":"coolme200","email":"2001-wms@163.com"},{"name":"akitasummer","email":"644171127@qq.com"},{"name":"niania","email":"ljracm@gmail.com"}],"homepage":"https://github.com/eggjs/egg/tree/next/tegg/core/eventbus-decorator","bugs":{"url":"https://github.com/eggjs/egg/issues"},"dist":{"shasum":"4ce993c1a7a4578c7239436e3ef106aeb40fb9d6","tarball":"http://registry-npm.ywwl.com/@eggjs/eventbus-decorator/download/@eggjs/eventbus-decorator-4.0.2-beta.5.tgz","fileCount":14,"integrity":"sha512-xMhFAAJRJizSL7GngDSIKO2CzjQ3XUbwGweWtE85nJrrP3AstPk8oYiIYayWmG9sOxN2+LnJIwA6j7RwQ0wHXA==","signatures":[{"sig":"MEUCIQD5b2+fBo1hcXqjZFgTMueoZlnGe95I2OvbPpvXsDdOawIgRbjtSIRhW+aExR2X3sua12A6YdCKvFCk830xCnoH6sQ=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@eggjs%2feventbus-decorator@4.0.2-beta.5","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":12465,"size":4223,"noattachment":false,"key":"/@eggjs/eventbus-decorator/-/@eggjs/eventbus-decorator-4.0.2-beta.5.tgz"},"main":"./dist/index.js","type":"module","_from":"file:eggjs-eventbus-decorator-4.0.2-beta.5.tgz","types":"./dist/index.d.ts","module":"./dist/index.js","engines":{"node":">=22.18.0"},"exports":{".":"./dist/index.js","./package.json":"./package.json"},"scripts":{"typecheck":"tsgo --noEmit"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:270a2d84-b9b0-4980-8f9d-ea91c8c5edd5"}},"_resolved":"/tmp/7ba87967eaa9e280c0f8b8596e218387/eggjs-eventbus-decorator-4.0.2-beta.5.tgz","_integrity":"sha512-xMhFAAJRJizSL7GngDSIKO2CzjQ3XUbwGweWtE85nJrrP3AstPk8oYiIYayWmG9sOxN2+LnJIwA6j7RwQ0wHXA==","repository":{"url":"git+https://github.com/eggjs/egg.git","type":"git","directory":"tegg/core/eventbus-decorator"},"_npmVersion":"11.9.0","description":"tegg eventbus decorator","directories":{},"_nodeVersion":"24.14.0","dependencies":{"@eggjs/tegg-types":"4.0.2-beta.5","@eggjs/core-decorator":"4.0.2-beta.5","@eggjs/tegg-common-util":"4.0.2-beta.5"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"coffee":"5","typescript":"^5.9.3","@types/node":"^24.10.2"},"_npmOperationalInternal":{"tmp":"tmp/eventbus-decorator_4.0.2-beta.5_1773666093726_0.2879019463352521","host":"s3://npm-registry-packages-npm-production"},"readme":"# `@eggjs/eventbus-decorator`\n\n## Usage\n\n### emit event\n\n```ts\nimport { EventBus } from '@eggjs/eventbus-decorator'\n\n// Define event first.\n// Ts can check event and args type for you.\ndeclare module '@eggjs/eventbus-decorator' {\n  interface Events {\n    hello: (msg: string) => Promise<void>;\n  }\n}\n\nclass Foo {\n  @Inject()\n  private readonly eventBus: EventBus;\n\n  bar() {\n    this.eventBus.emit('hello', '01');\n  }\n}\n```\n\n### cork events\n\nCache events in memory until uncork.\n\n```ts\nclass Foo {\n  @Inject()\n  private readonly eventBus: ContextEventBus;\n\n  bar() {\n    this.eventBus.cork();\n    // ...do something\n    this.eventBus.emit('hello', '01');\n    // ...do other things\n    \n    // emit all cached events\n    this.eventBus.uncork();\n  }\n}\n```\n\n### handle event\n\n```ts\n@Event('hello')\nexport class Foo {\n  async handle(msg: string): Promise<void> {\n    console.log('msg: ', msg);\n  }\n}\n```\n\n### handle multiple event\n```ts\n@Event('hello')\n@Event('hi')\nexport class Foo {\n  async handle(msg: string): Promise<void> {\n    console.log('msg: ', msg);\n  }\n}\n```\n\n### inject event context \ninject event context  if you want to know which event is being handled.\nThe context param must be the first param\n\n```ts\n@Event('hello')\n@Event('hi')\nexport class Foo {\n  async handle(@EventContext() ctx: IEventContext, msg: string):Promise<void> {\n    console.log('eventName: ', ctx.eventName);\n    console.log('msg: ', msg);\n  }\n}\n```\n","publish_time":1773666093873,"_cnpm_publish_time":1773666093873,"dist-tags":{"alpha":"3.57.15-alpha.0","beta":"4.0.2-beta.27","beta-v3":"3.74.0-beta.3","latest":"4.1.0","rc":"4.0.2-rc.1"}}