{"id":20723388,"url":"https://github.com/yss14/node-redis-eventbus","last_synced_at":"2026-05-08T05:50:16.240Z","repository":{"id":65462503,"uuid":"116826342","full_name":"yss14/node-redis-eventbus","owner":"yss14","description":"A simple event bus powered by node-redis to communicate between multiple node instances","archived":false,"fork":false,"pushed_at":"2018-03-21T08:08:21.000Z","size":59,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-04-26T22:22:40.705Z","etag":null,"topics":["eventbus","eventbus-library","events","node-redis","nodejs","pubsub","redis"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yss14.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-01-09T14:27:31.000Z","updated_at":"2018-03-21T08:08:22.000Z","dependencies_parsed_at":"2023-01-24T15:45:27.125Z","dependency_job_id":null,"html_url":"https://github.com/yss14/node-redis-eventbus","commit_stats":{"total_commits":30,"total_committers":3,"mean_commits":10.0,"dds":0.06666666666666665,"last_synced_commit":"d94250260bafc7fcd236764024e4f58a58e413c9"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yss14%2Fnode-redis-eventbus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yss14%2Fnode-redis-eventbus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yss14%2Fnode-redis-eventbus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yss14%2Fnode-redis-eventbus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yss14","download_url":"https://codeload.github.com/yss14/node-redis-eventbus/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242997846,"owners_count":20219239,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["eventbus","eventbus-library","events","node-redis","nodejs","pubsub","redis"],"created_at":"2024-11-17T04:08:32.397Z","updated_at":"2025-12-24T05:34:37.472Z","avatar_url":"https://github.com/yss14.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![NPM](https://nodei.co/npm/node-redis-eventbus.png)](https://npmjs.org/package/node-redis-eventbus)\n[\u003cimg src=\"https://yss14.visualstudio.com/_apis/public/build/definitions/c04cf627-33a9-4b7d-920b-a1d2c3867087/1/badge\"/\u003e](https://yss14.visualstudio.com/node-redis-eventbus/_build/index?definitionId=1)\n\n# node-redis-eventbus\nA simple event bus powered by redis to communicate between multiple node instances.\n\n## Install\n```bash\nnpm install --save node-redis-eventbus\n\n//or\n\nyarn add node-redis-eventbus\n```\n\n## Usage\n## Async/await pattern\n```typescript\n//Wrap example by an async function\n(async () =\u003e {\n\t//Create new event bus instance with a unique identifier\n\tconst eventBus = await EventBus.create('myEventBus');\n\n\t//Add listener and wait until it's binded successfully\n\tawait eventBus.on('msg', (payload) =\u003e {\n\t\tconsole.log(`Received message: ${payload}`);\n\n\t\teventBus.destory();\n\n\t\tprocess.exit();\n\t});\n\n\tconsole.log('Listening to msg event');\n\n\tsetTimeout(() =\u003e {\n\t\t//Emit event to all listeners on the 'msg' event\n\t\teventBus.emit('msg', 'Hello');\n\t}, 5000);\n})();\n\n//Somewhere else in your code get reference to the event bus\nconst eventBus = EventBus.getByName('myEventBus');\neventBus.emit('msg', 'Hello?');\n```\n\n## Promise style\n```typescript\n//Create new event bus instance with a unique identifier\nEventBus.create('myEventBus').then((eventBus) =\u003e {\n\t//Add listener and wait until it's binded successfully\n\teventBus.on('msg', (payload) =\u003e {\n\t\tconsole.log(`Received message: ${payload}`);\n\n\t\teventBus.destory();\n\n\t\tprocess.exit();\n\t}).then(() =\u003e {\n\t\tconsole.log('Listening to msg event');\n\n\t\tsetTimeout(() =\u003e {\n\t\t\teventBus.emit('msg', 'Hello');\n\t\t}, 5000);\n\t})\n})\n\n//Somewhere else in your code get reference to the event bus\nconst eventBus = EventBus.getByName('myEventBus');\neventBus.emit('msg', 'Hello?');\n```\n\n## Docs\n```typescript\n//Register listener for specific event. To avoid sideeffects, you have to wait for the promise to resolve\non\u003cT\u003e(event: string, callback: (payload: T) =\u003e void): Promise\u003cvoid\u003e;\n\n//Emit event on the event bus with passed payload\nemit\u003cT\u003e(event: string, payload: T): void;\n\n//Sends ping to all listeners and waits maximum \u003ctimeout\u003e milliseconds\n//Returns true if at least \u003cminResponseCount\u003e clients responded, false otherwise\nping(timeout?: number, minResponseCount?: number): Promise\u003cboolean\u003e;\n\n//Destroy this event bus instance and disconnect from redis\n//Watch out: If there are other clients connected, these instances will not be destroyed!\ndestroy(): void;\n\n//Property which indicated wether the event bus is connected\nconnected: boolean;\n\n//Creates a new event bus with a unique name and optional node-redis client options\nstatic create(name: string, clientOpts?: Redis.ClientOpts): Promise\u003cEventBus\u003e;\n\n//Access existing event bus instance by unique name\nstatic getByName(name: string): EventBus;\n```\n\n## Typescript\nThis package automatically ships a `d.ts` definition file!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyss14%2Fnode-redis-eventbus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyss14%2Fnode-redis-eventbus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyss14%2Fnode-redis-eventbus/lists"}