Skip to content

feat: event-bus to be async to allow for non-blocking callbacks#106

Merged
Swiftwork merged 6 commits intomainfrom
feat/rewrite-to-async
Jun 23, 2025
Merged

feat: event-bus to be async to allow for non-blocking callbacks#106
Swiftwork merged 6 commits intomainfrom
feat/rewrite-to-async

Conversation

@Swiftwork
Copy link
Copy Markdown
Contributor

BREAKING CHANGE: subscribe is now asynchronous and requires await before call to unsubscribe.

…callbacks

BREAKING CHANGE: `subscribe` is now asynchronous and requires `await` before call to `unsubscribe`
@Swiftwork
Copy link
Copy Markdown
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.

@Swiftwork Swiftwork requested a review from Copilot June 22, 2025 21:59
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 subscribe and publish methods to return Promises for async callbacks.
  • Replace raw object storage with a Map<string,ChannelSubscription> and integrate fast-equals + jsonschema Validator.
  • 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 logLevel to 'error', but the doc comment says 'info' is the default. Align the implementation and docs on the chosen default log level.
      logLevel: 'error',

Comment thread src/event-bus.ts Outdated
Comment thread src/event-bus.ts
Comment thread src/event-bus.spec.ts Outdated
Comment thread docs/react-component.js Outdated
Comment thread package.json
BREAKING CHANGE: wildcard channels now get the original channel
@Swiftwork Swiftwork merged commit e5cb0cd into main Jun 23, 2025
3 checks passed
@github-actions
Copy link
Copy Markdown

🎉 This PR is included in version 3.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@Swiftwork Swiftwork deleted the feat/rewrite-to-async branch July 30, 2025 09:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request released

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants