Skip to main content
Home

event broker based on javascript generator etiher synchronous and asynchronous

This package works with Node.js, Bun, BrowsersIt is unknown whether this package works with Cloudflare Workers, Deno
It is unknown whether this package works with Cloudflare Workers
This package works with Node.js
It is unknown whether this package works with Deno
This package works with Bun
This package works with Browsers
JSR Score
88%
Published
a year ago (2.0.0)
class AsyncEventBroker

An asynchronous event broker that support a single event handler.

Type Parameters

ListenEvent extends BaseEvent

The type of event to listen for.

ReplyEvent extends BaseEvent = ListenEvent

The type of event to reply with.

Properties

private
abstract
_listener: AsyncGenerator<ReplyEvent | undefined, ReplyEvent | void, ListenEvent | { [stopSymbol]?: boolean; }>
private
abstract
_listenerId: ListenerID
readonly
isOn: boolean

Checks if the event broker is currently listening.

deprecated
readonly
isStarted: boolean

alias for isOn property

Methods

Sends an event to the listener.

Sends an event and waits for a reply.

private
listen(listener: AsyncBrokerListener<ListenEvent, ReplyEvent>): AsyncGenerator<ReplyEvent | undefined, ReplyEvent | void, ListenEvent | { [stopSymbol]?: boolean; }>

An asynchronous generator function that listens for events.

Stops listening for events.

Starts listening for events.

Starts listening for sigle event and then off.

deprecated
send(event: ListenEvent): Promise<boolean>

alias for emit method

alias for emitWithReply method

deprecated
start(handler: AsyncEventHandler<ListenEvent, ReplyEvent>): Promise<ListenerID | undefined>

alias for on method

deprecated
stop(listenerId: ListenerID): Promise<boolean>

alias for off method

New Ticket: Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@soulsoftware/event-broker

Import symbol

import { AsyncEventBroker } from "@soulsoftware/event-broker";
or

Import directly with a jsr specifier

import { AsyncEventBroker } from "jsr:@soulsoftware/event-broker";

Add Package

pnpm i jsr:@soulsoftware/event-broker
or (using pnpm 10.8 or older)
pnpm dlx jsr add @soulsoftware/event-broker

Import symbol

import { AsyncEventBroker } from "@soulsoftware/event-broker";

Add Package

yarn add jsr:@soulsoftware/event-broker
or (using Yarn 4.8 or older)
yarn dlx jsr add @soulsoftware/event-broker

Import symbol

import { AsyncEventBroker } from "@soulsoftware/event-broker";

Add Package

vlt install jsr:@soulsoftware/event-broker

Import symbol

import { AsyncEventBroker } from "@soulsoftware/event-broker";

Add Package

npx jsr add @soulsoftware/event-broker

Import symbol

import { AsyncEventBroker } from "@soulsoftware/event-broker";

Add Package

bunx jsr add @soulsoftware/event-broker

Import symbol

import { AsyncEventBroker } from "@soulsoftware/event-broker";