Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Node CI
on:
push:
pull_request:
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- run: npm install
- run: npm test
19 changes: 18 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ A small library written in TypeScript that gives you a publish / subscribe appli

## Installation

Both ESM and CommonJS builds are provided.
Both ESM and CommonJS builds are provided. Use the default import in modern
bundlers or `require` in Node's CommonJS mode.

`npm install app-bus --save`

Expand Down Expand Up @@ -37,6 +38,9 @@ Both ESM and CommonJS builds are provided.

//Publish an event immediately without a payload
appBus.publish(myEventName).now();

//Publish asynchronously using a microtask
appBus.publish(myEventName).with(myPayload).async();

//Unsubscribe when done
appBus.unSubscribe(mySubscriber).from(myEventName);
Expand Down Expand Up @@ -99,6 +103,19 @@ Both ESM and CommonJS builds are provided.

//Also clear all posts
appBus.clear.posts.all();

## TypeScript Example

interface Events {
'user.created': { id: number };
'user.deleted': { id: number };
}

const typedBus = AppBusFactory.new<Events>();
typedBus.subscribe((payload) => {
console.log(payload.id);
}).to('user.created');
typedBus.publish('user.created').with({ id: 1 }).now();

## Tests

Expand Down
Loading