{"_id":"@alister.codes/tsbus","name":"@alister.codes/tsbus","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@alister.codes/tsbus","version":"1.0.0","description":"Actually simple TS event bus with no dependencies ever","main":"dist/index.js","types":"dist/index.d.ts","scripts":{"test":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/alisterg/JsEventBus.git"},"author":{"name":"alisterg"},"license":"MIT","bugs":{"url":"https://github.com/alisterg/JsEventBus/issues"},"keywords":["event","pubsub"],"homepage":"https://github.com/alisterg/JsEventBus#readme","devDependencies":{"@types/jest":"^27.5.2","jest":"^28.1.0","prettier":"^2.6.2","ts-jest":"^28.0.3"},"gitHead":"099ffaa089bf513f8b419d5926d35dbb7bf6f7e4","_id":"@alister.codes/tsbus@1.0.0","_nodeVersion":"14.16.1","_npmVersion":"7.11.0","dist":{"integrity":"sha512-p+Jh+I4du4vLi4driSj8bMcbN1MbxNPQL4WVMsJYguUcWFbhoDMYjBRpLDL/LhHyH9gxCXVS+wrReA80pSN4Kw==","shasum":"4f3faa5abcf2b9d90bfa5f825774c0a41beac0ad","tarball":"https://registry.npmjs.org/@alister.codes/tsbus/-/tsbus-1.0.0.tgz","fileCount":7,"unpackedSize":4919,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDFcss5F3YQIoaRm2Tp0bJ5zv5SCeRENPH1mH2GkCd7mgIgB1EDicLaa6rtzr3zuLbaceH/u2MQ6Zaaai9RxL1eTT0="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJimGaeACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpddhAAkEJ979BlV36aH7Jo7YX0m5Rzn/i9ImS3fNbPvoqQnwj3vK5K\r\n7ThBXqGBsTlJXUMsNAABJZStPbmojvXXh9mzpIQsz3JPgmwbhbSu5v47NNmu\r\npeQ/vkY+0DcVbKd/WeDS+dJPPAXJl31kJp5pmIBi6z/pk13RDgOa2yWEMaYU\r\nhJCgALHRw+7o65WCEvps1xxqfDuciJt8fUnwqu8Cmi2p87uKdCwTP26mRAzi\r\nlhQJbsN1CqhhF/p+P7ZESENgNLLbRNzVPlQMn7dP+AiNMjIEewIID0w3QHyU\r\nFwAdBTpeA95cTBA8Xtr9uR/VeBIawa4nkZGkr0ftJk1KNrLZ3pbOd35KsmO+\r\nET7CorBUgWVgh+o2pU+MKGAprMvJqEM+6y4cAWIn63GZHs67JigYi6KDcOkA\r\njpTfpFoCo73bjtpElfs93Wq9n8rHh0bMjkSMAWsJR0rQ2mL8iZCMO7qqyy8F\r\nUhlYb4+DknXpCe7e4DzRmPdWhVKgzaaEelT1InlMmWzG1Ysyim6v1wAOgiRJ\r\nd9ayzfLsQ4uGTtVJ564PmfWQoQOu404qOLSRQ5H7GJ4vt2BMGh3qPaptyEiJ\r\nNinmhQE8xE8NovzPu3hU0+uiIHz1hawg5nFkPF0FUpIY7UlTIfyQaOiR+zBY\r\nzrexB/StSRq8Ca36kD/BP91hpmUfkpqItCE=\r\n=iPqI\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"alister.codes","email":"ionic_green.0e@icloud.com"},"directories":{},"maintainers":[{"name":"alister.codes","email":"ionic_green.0e@icloud.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/tsbus_1.0.0_1654154910495_0.09261233932892998"},"_hasShrinkwrap":false}},"time":{"created":"2022-06-02T07:28:30.431Z","1.0.0":"2022-06-02T07:28:30.696Z","modified":"2022-06-02T07:28:30.827Z"},"maintainers":[{"name":"alister.codes","email":"ionic_green.0e@icloud.com"}],"description":"Actually simple TS event bus with no dependencies ever","homepage":"https://github.com/alisterg/JsEventBus#readme","keywords":["event","pubsub"],"repository":{"type":"git","url":"git+https://github.com/alisterg/JsEventBus.git"},"author":{"name":"alisterg"},"bugs":{"url":"https://github.com/alisterg/JsEventBus/issues"},"license":"MIT","readme":"# TsBus\n\nA minimal event bus for you to implement the [pub/sub](https://en.wikipedia.org/wiki/Publish–subscribe_pattern)\npattern with.\n\nI have made it a class so you can create a new bus per use case.\n\n- Zero dependencies\n- Simple & easy to use\n- Feature complete\n\n# How to use\n\nAssuming we have the following...\n\n```js\nconst salesEventBus = new TsBus();\n\nfunction handler(eventData) {\n  console.log(\"Received event: \", eventData);\n}\n```\n\n## .on\n\n```js\n// Register the event\nsalesEventBus.on(\"MY_EVENT\", handler);\n```\n\nYou can register multiple handlers for a specific event. You can register a handler with multiple events.\n\n## .emit\n\n```js\n// Emit the event (as many times as you want). `handler` is called each time the event is emitted.\nsalesEventBus.emit(\"MY_EVENT\");\nsalesEventBus.emit(\"MY_EVENT\");\n```\n\nAs long as a handler is registered for an event, it will be called every time you emit the event.\n\n## .off\n\n```js\nsalesEventBus.off(\"MY_EVENT\", handler);\n// Handler will *not* be called again\nsalesEventBus.emit(\"MY_EVENT\");\n```\n\n## .once\n\nUse `EventBus.once` to call a handler only the first time the relevant event is emitted.\n\n```js\n// Register the event\nsalesEventBus.once(\"MY_EVENT\", handler);\nsalesEventBus.emit(\"MY_EVENT\");\n// Handler will *not* be called again\nsalesEventBus.emit(\"MY_EVENT\");\n```\n","readmeFilename":"README.md"}