{"name":"@eggjs/eventbus-decorator","version":"4.0.0-beta.7","keywords":["egg","typescript","eventbus","eventemitter","tegg"],"author":{"name":"killagu","email":"killa123@126.com"},"license":"MIT","_id":"@eggjs/eventbus-decorator@4.0.0-beta.7","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":"akitasummer@outlook.com"}],"homepage":"https://github.com/eggjs/tegg/tree/next/core/eventbus-decorator","bugs":{"url":"https://github.com/eggjs/tegg/issues"},"dist":{"shasum":"97da67ed03bb9eded189351cfbd917db4e4233db","tarball":"http://registry-npm.ywwl.com/@eggjs/eventbus-decorator/download/@eggjs/eventbus-decorator-4.0.0-beta.7.tgz","fileCount":14,"integrity":"sha512-q3jlIBJi0a7JhQJLgdakKVd+7KgT+7akPEbzTDuwCRjixbQkl64K2ar/BLZG4pKM1Tj/weoL1koKvGOLQjGVJA==","signatures":[{"sig":"MEYCIQCUpFXeo1pq4IhKPUnMyB2mD9of0BFk7G/sLIZQPpikBQIhAOylN9jJ/ti19ZbwqxzqMuHpAJ5cgki28SkcIF/s/2qh","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@eggjs%2feventbus-decorator@4.0.0-beta.7","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":12615,"size":4288,"noattachment":false,"key":"/@eggjs/eventbus-decorator/-/@eggjs/eventbus-decorator-4.0.0-beta.7.tgz"},"main":"./dist/index.js","type":"module","_from":"file:eggjs-eventbus-decorator-4.0.0-beta.7.tgz","types":"./dist/index.d.ts","module":"./dist/index.js","engines":{"node":">=22.18.0"},"exports":{".":"./dist/index.js","./package.json":"./package.json"},"scripts":{"build":"tsdown","clean":"rimraf dist","typecheck":"tsc --noEmit"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:f9bfdb1f-db51-47a9-8223-41f81fff3d7c"}},"_resolved":"/tmp/c7e01c02e013263980646ac126b07e30/eggjs-eventbus-decorator-4.0.0-beta.7.tgz","_integrity":"sha512-q3jlIBJi0a7JhQJLgdakKVd+7KgT+7akPEbzTDuwCRjixbQkl64K2ar/BLZG4pKM1Tj/weoL1koKvGOLQjGVJA==","repository":{"url":"git+ssh://git@github.com/eggjs/tegg.git","type":"git","directory":"core/eventbus-decorator"},"_npmVersion":"11.6.1","description":"tegg eventbus decorator","directories":{},"_nodeVersion":"22.20.0","dependencies":{"@eggjs/tegg-types":"4.0.0-beta.7","@eggjs/core-decorator":"4.0.0-beta.7","@eggjs/tegg-common-util":"4.0.0-beta.7"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"coffee":"^5.1.0","tsdown":"^0.15.6","typescript":"^5.9.3","@types/node":"^22.10.5","unplugin-unused":"^0.5.3"},"_npmOperationalInternal":{"tmp":"tmp/eventbus-decorator_4.0.0-beta.7_1759585220168_0.48919584969323315","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":1759585220360,"_cnpm_publish_time":1759585220360,"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"}}