{"id":20060671,"url":"https://github.com/ficusjs/ficusjs-event-bus","last_synced_at":"2025-10-16T15:40:53.032Z","repository":{"id":103429413,"uuid":"367787557","full_name":"ficusjs/ficusjs-event-bus","owner":"ficusjs","description":"Publish/subscribe event bus for FicusJS","archived":false,"fork":false,"pushed_at":"2023-10-30T03:18:52.000Z","size":842,"stargazers_count":0,"open_issues_count":6,"forks_count":0,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-02-12T22:18:52.204Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://docs.ficusjs.org/event-bus/","language":"JavaScript","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/ficusjs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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},"funding":{"github":"ficusjs"}},"created_at":"2021-05-16T04:52:10.000Z","updated_at":"2023-01-31T18:54:14.000Z","dependencies_parsed_at":"2023-11-09T14:15:09.132Z","dependency_job_id":null,"html_url":"https://github.com/ficusjs/ficusjs-event-bus","commit_stats":{"total_commits":15,"total_committers":1,"mean_commits":15.0,"dds":0.0,"last_synced_commit":"d11f1b95b133a4a826840357b0344539f57cc806"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ficusjs%2Fficusjs-event-bus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ficusjs%2Fficusjs-event-bus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ficusjs%2Fficusjs-event-bus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ficusjs%2Fficusjs-event-bus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ficusjs","download_url":"https://codeload.github.com/ficusjs/ficusjs-event-bus/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241488201,"owners_count":19970829,"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":[],"created_at":"2024-11-13T13:16:15.140Z","updated_at":"2025-10-16T15:40:48.013Z","avatar_url":"https://github.com/ficusjs.png","language":"JavaScript","funding_links":["https://github.com/sponsors/ficusjs"],"categories":[],"sub_categories":[],"readme":"# FicusJS event bus\n\nFicusJS event bus provides functions for a fast, lightweight publish/subscribe event bus.\n\nFor communication between components without triggering a re-render, the event bus object provides a topic-based publish/subscribe API.\n\n**The event bus will be created as a singleton - this ensures only one instance exists.**\n\nFor documentation visit [https://docs.ficusjs.org/event-bus/](https://docs.ficusjs.org/event-bus/)\n\n## Getting started\n\nThe `createEventBus` function creates a new event bus instance.\n\n```js\nimport { createEventBus } from 'https://cdn.skypack.dev/@ficusjs/event-bus'\n\nconst eventBus = createEventBus()\n```\n\nThe `getEventBus` function returns the default event bus instance.\n\n```js\nimport { getEventBus } from 'https://cdn.skypack.dev/@ficusjs/event-bus'\n\nconst eventBus = getEventBus()\n```\n\nThe `withEventBus` function creates a new event bus instance and adds it to the context of the component.\n\n```js\nimport { createCustomElement, createEventBus, withEventBus } from 'https://cdn.skypack.dev/ficusjs@6'\nimport { html, renderer } from 'https://cdn.skypack.dev/@ficusjs/renderers@5/uhtml'\n\nconst eventBus = createEventBus()\n\n// A new component\ncreateCustomElement(\n  'my-component',\n  withEventBus(eventBus, {\n    renderer,\n    handleEvent (data) {\n      /* handle event here */\n    },\n    mounted () {\n      this.events.subscribe('my-event', this.handleEvent)\n    },\n    render () {\n      /* handle render here */\n    }\n  })\n)\n```\n\n## Installation\n\nFicusJS event bus is part of [FicusJS](https://docs.ficusjs.org) but can also be installed independently in a number of ways.\n\n### CDN\n\nWe recommend using native ES modules in the browser.\n\n```html\n\u003cscript type=\"module\"\u003e\n  import { createEventBus, getEventBus, withEventBus } from 'https://cdn.skypack.dev/@ficusjs/event-bus'\n\u003c/script\u003e\n```\n\nFicusJS event bus is available on [Skypack](https://www.skypack.dev/view/@ficusjs/event-bus).\n\n### NPM\n\nFicusJS event bus works nicely with build tools such as Snowpack, Webpack or Rollup. If you are using a NodeJS tool, you can install the NPM package.\n\n```bash\nnpm install @ficusjs/event-bus\n```\n\n### Available builds\n\nFicusJS event bus only provides ES module builds. For legacy browsers or alternative modules such as CommonJS, it is recommended to use a build tool to transpile the code.\n\n## Development\n\nHow to set-up FicusJS event bus for local development.\n\n1. Clone the repository:\n\n```bash\ngit clone https://github.com/ficusjs/ficusjs-event-bus.git\n```\n\n2. Change the working directory\n\n```bash\ncd ficusjs-event-bus\n```\n\n3. Install dependencies\n\n```bash\nnpm install\n```\n\n4. Run the local development server\n\n```bash\nnpm run dev\n```\n\nThat's it! Now open http://localhost:8080 to see a local app.\n\n## License\n\nThis project is licensed under the MIT License - see the [`LICENSE`](LICENSE) file for details.\n\n## Contributing to FicusJS event bus\n\nAny kind of positive contribution is welcome! Please help us to grow by contributing to the project.\n\nIf you wish to contribute, you can work on any features you think would enhance the library. After adding your code, please send us a Pull Request.\n\n\u003e Please read [CONTRIBUTING](CONTRIBUTING.md) for details on our [CODE OF CONDUCT](CODE_OF_CONDUCT.md), and the process for submitting pull requests to us.\n\n## Support\n\nWe all need support and motivation. FicusJS is not an exception. Please give this project a ⭐️ to encourage and show that you liked it. Don't forget to leave a star ⭐️ before you move away.\n\nIf you found the library helpful, please consider [sponsoring us](https://github.com/sponsors/ficusjs).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fficusjs%2Fficusjs-event-bus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fficusjs%2Fficusjs-event-bus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fficusjs%2Fficusjs-event-bus/lists"}