feat: event-bus to be async to allow for non-blocking callbacks#106
Merged
feat: event-bus to be async to allow for non-blocking callbacks#106
Conversation
…callbacks BREAKING CHANGE: `subscribe` is now asynchronous and requires `await` before call to `unsubscribe`
This was referenced Jan 31, 2025
Contributor
Author
|
Delaying PR to research if a more browser-friendly JSON schema library like Ajv should be used, which could also be a breaking change. |
There was a problem hiding this comment.
Pull Request Overview
This PR makes the EventBus API fully asynchronous and non-blocking, replaces the old schema/validation implementation, and adds structured logging and replay controls.
- Convert
subscribeandpublishmethods to return Promises for async callbacks. - Replace raw object storage with a
Map<string,ChannelSubscription>and integratefast-equals+jsonschemaValidator. - Introduce log levels, replay clearing, and update documentation/tests accordingly.
Reviewed Changes
Copilot reviewed 8 out of 10 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/event-bus.ts | Refactor to async API, add Map-based subscriptions, logging, validation, and clearReplay. |
| src/event-bus.spec.ts | Update tests to await async subscribe/publish, cover new features, and fix wildcard behavior. |
| rollup.config.js | Add JSON plugin, node:fs import, external deps via regex, and adjust outputs. |
| package.json | Bump version/deps, add exports and sideEffects, update packageManager. |
| docs/react-component.js | Rewrite example into custom hook with async init/cleanup. |
| README.md | Extend API docs for constructor options, async methods, clearReplay. |
| .github/workflows/ci.yml | Extend CI matrix to Node 22.x & 24.x. |
| .github/workflows/cd.yml | Update CD to target Node 24.x. |
Comments suppressed due to low confidence (1)
src/event-bus.ts:80
- The code defaults
logLevelto'error', but the doc comment says'info'is the default. Align the implementation and docs on the chosen default log level.
logLevel: 'error',
BREAKING CHANGE: wildcard channels now get the original channel
|
🎉 This PR is included in version 3.0.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
BREAKING CHANGE:
subscribeis now asynchronous and requiresawaitbefore call tounsubscribe.