{"name":"@eggjs/eventbus-decorator","version":"3.2.2","keywords":["egg","typescript","eventbus","eventemitter","tegg"],"author":{"name":"killagu","email":"killa123@126.com"},"license":"MIT","_id":"@eggjs/eventbus-decorator@3.2.2","homepage":"https://github.com/eggjs/tegg","bugs":{"url":"https://github.com/eggjs/tegg/issues"},"dist":{"shasum":"552577507b7c4650da8382a5da90048779d48a28","tarball":"http://registry-npm.ywwl.com/@eggjs/eventbus-decorator/download/@eggjs/eventbus-decorator-3.2.2.tgz","fileCount":11,"integrity":"sha512-PQuWCem6hqgDkT0iQtA2YMOrUKr5h8ApLFwLNtrSABY5HAP5Rznifcw7PUCCWPyDCeWFVZk+S1qcddwD+1cOWQ==","signatures":[{"sig":"MEQCIDFtzpzmZhGvuFKo01qtGjnJcWobs28/IEXKif6TjT3AAiAqXwHUtHBXwgTf0+RtP2RREo4uMtMJMe2Cm+48wzeAfw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":9568,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjt4zwACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrZyg//fesUU+VWcdquGlzk0sR4kMT77R+25Bxz/4/t0xJnYWwg8Mp/\r\nmKZlaYe7Xa/hbOnN29h0PbzHRLjAWpI+AMbf+38NHTclmcez1vaamg6r3gIO\r\npNFx3oDq//xhxosjCSZ1M+ueXK1E+zgphLq8m0QPHVI/Ju7xACMEJMQ3OHuq\r\nVSr6O1HTeMnHRQEWdIz7xEgRKD1ng+eo9xR5DKTjzhZX5GLwFY7dErwwVIvZ\r\nUCpqIz2GbhvBichLGlgjJRahdtVo22FRNd7WfZqiD7rzJrAv4gmM9EgM8rRP\r\nG3SDq3bew1IaWUV0QlqXyJ+SWvIEz70lvjAhr8JKm7QUPKutt/sIs+Z7Kbt2\r\nhAHx6+SOZvo9RqxiveAApOke8XLPY5JhFcoFX+jOMUwBpnzvzsgFh/mhzS3s\r\ndDn1oxbwgdN6VBOd+46A6L4S21wL1OAgihE1Wi6+DBHlfgJlQp5H1e7fcTj0\r\nmBLPm1nsbxlf3Q/6w+ureW7RUJfucSM1X36btK9VcU14cOyOTsCVLcW8UOq4\r\nE4TZfHJgS9tIFIH1qB01TQVorHDMl7cGEEJybAaYFU+V70QbevLkUSr0MEjI\r\nW4Zin/YdXnsXweYZ07TzmTYWCqoRBRfl/xQjq3Iz5VhWHM7ksqtD9FKNg2NF\r\n4QSR/9EhMsfDXzVl5JHS6fCyClqNFSa37IQ=\r\n=WVao\r\n-----END PGP SIGNATURE-----\r\n","size":4108,"noattachment":false,"key":"/@eggjs/eventbus-decorator/-/@eggjs/eventbus-decorator-3.2.2.tgz"},"main":"dist/index.js","engines":{"node":">=14.0.0"},"gitHead":"1db4e5320a0ea19b450df7d99ab7939f3ad48f6e","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.0/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.2","@eggjs/tegg-common-util":"^3.2.2"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"coffee":"^5.4.0"},"_npmOperationalInternal":{"tmp":"tmp/eventbus-decorator_3.2.2_1672973552477_0.8843406181211797","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":1672973552631,"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":1672973552631,"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"}}