Skip to main content

Built and signed on GitHub Actions

A simple message bus used for swapping out formatting for messages in cli applications. This module exists primarily for the rt ("run-task") cli.

This package works with Bun, Cloudflare Workers, Node.js, Deno, Browsers
JSR Score
70%
Published
2 weeks ago (0.0.0)

@rt/message-bus

logo Work less. Do more.

Overview

A simple message bus used for swapping out formatting for messages in cli applications. This module exists primarily for the rt ("run-task") cli.

Basic Usage

import { Message, DefaultMessageBus } from str from '@rt/message-bus'

const bus = new DefaultMessageBus();

export class WriteMessage extends Message {
    constructor(public message: string) {
        super("write")
    }
}

const messages: Message[] = [];
bus.addListener((message) => {
    messages.push(message);
});

bus.send(new WriteMessage("test"));

console.log(messages.length);
console.log(messages[0].kind);
console.log((messages[0] as WriteMessage).message);

MIT License

Built and signed on
GitHub Actions
View transparency log

Add Package

deno add @rt/message-bus

Import symbol

import * as mod from "@rt/message-bus";

Add Package

npx jsr add @rt/message-bus

Import symbol

import * as mod from "@rt/message-bus";

Add Package

yarn dlx jsr add @rt/message-bus

Import symbol

import * as mod from "@rt/message-bus";

Add Package

pnpm dlx jsr add @rt/message-bus

Import symbol

import * as mod from "@rt/message-bus";

Add Package

bunx jsr add @rt/message-bus

Import symbol

import * as mod from "@rt/message-bus";