{"name":"@eggjs/eventbus-decorator","version":"3.2.3","keywords":["egg","typescript","eventbus","eventemitter","tegg"],"author":{"name":"killagu","email":"killa123@126.com"},"license":"MIT","_id":"@eggjs/eventbus-decorator@3.2.3","homepage":"https://github.com/eggjs/tegg","bugs":{"url":"https://github.com/eggjs/tegg/issues"},"dist":{"shasum":"0dcaaff0554b219afbce1a5dce741582f2a28763","tarball":"http://registry-npm.ywwl.com/@eggjs/eventbus-decorator/download/@eggjs/eventbus-decorator-3.2.3.tgz","fileCount":11,"integrity":"sha512-SvSRWk30oi09M3HLqTCx2YG2X04GW2C/bNySxuWxCVX9Bs06Z0kdtMW3z1weey8mcqsubjRK14gvmM+yUnZb3Q==","signatures":[{"sig":"MEYCIQCsjY49w81FIQEam+2jKqijK+wv7NOYPSByyoEXsGXwKAIhAIgxe6JvlySDfwoKxoE8tGxhf4G6pFWuXbq76Hckfp7E","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":9736,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjxW1sACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqAFg/+LuShOneVEm3fKPq/RXOrKJdC65feCGT8tbh0C3PcYrpi6GuO\r\n0EKyx1CnaxoFioB3ffdTilpmtjTC0Opxh/qEii0e5d4MihmkfywvUkfm8Xtl\r\nHaWm4L/zcLBaqHGBxIcEFZG1QU9Qyti8VAIouQJhPKbOdBvS0+JcPf3bW88q\r\n2eclXHDxEGcKVxHv2EDlPUiFVec89chgiaHY62d0xIbKAxBfVg3Cv5ngnEZt\r\nQY2dvvDvgJocv3hZHQpeGcDlLwuGgyeEYunlbx/Qw/99ZtCkEEYQ3/cDP782\r\nTcTds6fqhRbVroxpXrCK7/m5sWV8yj4Bf4/z2m2Eo7olWD/I0kCLVDWhsKhE\r\nyzctRdGz21+uG5Nyr9di/rRlQyxvADAcgnNeqwfnLOlh9q5+a1+XLIff6tsp\r\niTTcJqx/j2f8vDfnTvMqKbMsMimm269maOZpUxdhKMBGHw8BYCt+xcU2K6uo\r\nrkQdLfZpqaSVnfOsOtVN4HcJtqVNrghxPmvVpjK8tWVvWm3bHw6hXtXvLU3M\r\nk4z6yWnJUGJnCj1xL8DiuMkh4XA4WyD+anNZsz0jgTBuIfhyNqfckLi5LMJq\r\n6k2nQ5mM7mECHBja4qeRkaPs7DWkcM3ryT8IfKdexn3m4r4LIespv6tCuHRo\r\nkHJWXRQetds/X9QA+g+SPH7Wf67J1/D4v90=\r\n=HRFr\r\n-----END PGP SIGNATURE-----\r\n","size":4166,"noattachment":false,"key":"/@eggjs/eventbus-decorator/-/@eggjs/eventbus-decorator-3.2.3.tgz"},"main":"dist/index.js","engines":{"node":">=14.0.0"},"gitHead":"0b7337df36d745aaa6f874de0107812184af0183","scripts":{"tsc":"npm run clean && tsc -p ./tsconfig.json","test":"cross-env NODE_ENV=test NODE_OPTIONS='--no-deprecation' mocha","clean":"tsc -b --clean","tsc:pub":"npm run clean && tsc -p ./tsconfig.pub.json","prepublishOnly":"npm run tsc:pub"},"typings":"dist/index.d.ts","_npmUser":{"name":"killagu","email":"killa07071201@gmail.com"},"repository":{"url":"git+ssh://git@github.com/eggjs/tegg.git","type":"git","directory":"core/eventbus-decorator"},"_npmVersion":"lerna/6.4.1/node@v16.18.1+x64 (darwin)","description":"tegg eventbus decorator","directories":{},"_nodeVersion":"16.18.1","dependencies":{"typed-emitter":"^1.3.1","@eggjs/core-decorator":"^3.2.3","@eggjs/tegg-common-util":"^3.2.3"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"mocha":"^10.2.0","coffee":"^5.4.0","ts-node":"^10.9.1","cross-env":"^7.0.3","typescript":"^4.9.4","@types/node":"^18.11.18","@types/mocha":"^10.0.1"},"_npmOperationalInternal":{"tmp":"tmp/eventbus-decorator_3.2.3_1673882988045_0.5221210323147738","host":"s3://npm-registry-packages"},"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":1673882988222,"maintainers":[{"name":"akitasummer","email":"644171127@qq.com"},{"name":"gxkl","email":"gxkl203@gmail.com"},{"name":"gemwuu","email":"gemwuu@gmail.com"},{"name":"eggjs-admin","email":"fengmk2+eggjs@gmail.com"},{"name":"fengmk2","email":"fengmk2@gmail.com"},{"name":"atian25","email":"atian25@qq.com"},{"name":"dead_horse","email":"dead_horse@qq.com"},{"name":"wanghx","email":"whxaxes@gmail.com"},{"name":"hyj1991","email":"yeekwanvong@gmail.com"},{"name":"killagu","email":"killa07071201@gmail.com"},{"name":"coolme200","email":"2001-wms@163.com"},{"name":"mansonchor.zzw","email":"mansonchor1987@gmail.com"},{"name":"hubcarl","email":"hubcarl@126.com"}],"_cnpm_publish_time":1673882988222,"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"}}