{"id":15136332,"url":"https://github.com/nextcloud-libraries/nextcloud-event-bus","last_synced_at":"2025-08-24T00:15:57.369Z","repository":{"id":35146063,"uuid":"209787412","full_name":"nextcloud-libraries/nextcloud-event-bus","owner":"nextcloud-libraries","description":"A event bus to communicate between Nextcloud components https://npmjs.org/@nextcloud/event-bus","archived":false,"fork":false,"pushed_at":"2024-10-26T01:54:17.000Z","size":3813,"stargazers_count":5,"open_issues_count":3,"forks_count":3,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-10-29T20:55:27.531Z","etag":null,"topics":["eventbus","events","nextcloud-plugin"],"latest_commit_sha":null,"homepage":"https://nextcloud-libraries.github.io/nextcloud-event-bus/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nextcloud-libraries.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-09-20T12:38:29.000Z","updated_at":"2024-10-26T01:54:20.000Z","dependencies_parsed_at":"2023-07-28T16:25:15.287Z","dependency_job_id":"c4acfeb0-9ee4-4663-af23-c2e567815912","html_url":"https://github.com/nextcloud-libraries/nextcloud-event-bus","commit_stats":{"total_commits":705,"total_committers":16,"mean_commits":44.0625,"dds":0.4312056737588652,"last_synced_commit":"5b21db1c6cbb366f62f517ded98d0f1dd160dd64"},"previous_names":["nextcloud-libraries/nextcloud-event-bus","nextcloud/nextcloud-event-bus"],"tags_count":24,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nextcloud-libraries%2Fnextcloud-event-bus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nextcloud-libraries%2Fnextcloud-event-bus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nextcloud-libraries%2Fnextcloud-event-bus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nextcloud-libraries%2Fnextcloud-event-bus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nextcloud-libraries","download_url":"https://codeload.github.com/nextcloud-libraries/nextcloud-event-bus/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246262490,"owners_count":20749170,"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","events","nextcloud-plugin"],"created_at":"2024-09-26T06:20:56.555Z","updated_at":"2025-03-30T00:30:30.417Z","avatar_url":"https://github.com/nextcloud-libraries.png","language":"TypeScript","readme":"\u003c!--\n  - SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors\n  - SPDX-License-Identifier: CC0-1.0\n--\u003e\n\n# @nextcloud/event-bus\n\n[![REUSE status](https://api.reuse.software/badge/github.com/nextcloud-libraries/nextcloud-event-bus)](https://api.reuse.software/info/github.com/nextcloud-libraries/nextcloud-event-bus)\n[![Build Status](https://img.shields.io/github/actions/workflow/status/nextcloud/nextcloud-event-bus/node.yml?branch=master)](https://github.com/nextcloud/nextcloud-event-bus/actions/workflows/node.yml?query=branch%3Amaster) [![Code coverage](https://img.shields.io/codecov/c/gh/nextcloud/nextcloud-event-bus/master)](https://app.codecov.io/gh/nextcloud/nextcloud-event-bus) [![npm](https://img.shields.io/npm/v/@nextcloud/event-bus.svg)](https://www.npmjs.com/package/@nextcloud/event-bus)\n[![Documentation](https://img.shields.io/badge/Documentation-online-brightgreen)](https://nextcloud.github.io/nextcloud-event-bus/)\n\nA simple event bus to communicate between Nextcloud components.\n\n## Installation\n\n```sh\nnpm install @nextcloud/event-bus --save\n```\n\n```sh\nyarn add @nextcloud/event-bus\n```\n\n## Usage\n\n```js\nimport { emit, subscribe, unsubscribe } from '@nextcloud/event-bus'\n\nconst h = (e) =\u003e console.info(e)\n\nsubscribe('a', h)\nsubscribe('b', h)\n\nemit('a', {\n\tdata: 123,\n})\n\nunsubscribe('a', h)\nunsubscribe('b', h)\n```\n\n### Typed events\n\nIt is also possible to type events, which allows type infering on the event-bus methods like `emit`, `subscribe` and `unsubscribe`.\nTo register new events, simply extend the `NextcloudEvents` interface:\n\n1. Create a file like `event-bus.d.ts`:\n\n```ts\ndeclare module '@nextcloud/event-bus' {\n\tinterface NextcloudEvents {\n\t\t'example-app:awesomeness:increased': { level: number }\n\t}\n}\n\nexport {}\n```\n\n2. Now if you use any of the event bus functions, the parameters will automatically be typed correctly:\n\n```ts\nimport { subscribe } from '@nextcloud/event-bus'\n\nsubscribe('example-app:awesomeness:increased', (event) =\u003e {\n\t// \"event\" automatically infers type { level: number}\n\tconsole.log(event.level)\n})\n```\n\n## Naming convention\n\nTo stay consistent, we encourage you to use the following syntax when declaring events\n\n`app-id:object:verb`\n\n### Examples:\n\n- `nextcloud:unified-search:closed`\n- `files:node:uploading`\n- `files:node:uploaded`\n- `files:node:deleted`\n- `contacts:contact:deleted`\n- `calendar:event:created`\n- `forms:answer:updated`\n\n## Development\n\n```sh\nnpm install\n\nnpm run build\nnpm run test\n```\n\n### Requirements\n\n- [Node 20 or higher](https://nodejs.org/en/download/)\n- [NPM 10 or higher](https://www.npmjs.com/package/npm)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnextcloud-libraries%2Fnextcloud-event-bus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnextcloud-libraries%2Fnextcloud-event-bus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnextcloud-libraries%2Fnextcloud-event-bus/lists"}