New:Introducing Socket Scanning for VS Code Marketplace Extensions.Learn more →
Get Started

@bimetal/broker-broadcast

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bimetal/broker-broadcast

BroadcastChannel adapter for @bimetal/broker — cross-tab, same-origin pub/sub. Zero external dependencies.

latest
npmnpm
Version
0.42.0
Version published
Weekly downloads
28
-88.28%
Maintainers
1
Weekly downloads
 
Created
Source

@bimetal/broker-broadcast

Scope — cross-tab pub/sub on ONE origin, in ONE browser. No server, no cross-origin, and no ordering guarantee: the port broker reports capabilities.ordering: 'none', so a receiver must tolerate out-of-order delivery (see bridgeBrokerToEventStore and the cookbook recipe).

BroadcastChannel adapter for @bimetal/broker — cross-tab, same-origin pub/sub. Every browser tab/worker that opens a broker on the same channel name forms one bus. Zero external dependencies; a thin wrapper over createPortBroker.

Installation

npm install @bimetal/broker-broadcast @bimetal/broker

Usage

import { createBroadcastBroker } from '@bimetal/broker-broadcast';

const broker = createBroadcastBroker({ channel: 'bimetal' });

broker.subscribe('calendar.created', (msg, topic) => {
  // fires in THIS tab and every other tab on the 'bimetal' channel
});

await broker.publish('calendar.created', { id: '1' });

What's Inside

  • createBroadcastBroker(options) → a full Broker<TMessage> (plus close()/flush()).
    • channel — the BroadcastChannel name; the shared bus identity.
    • factory? — override channel creation (default new BroadcastChannel(name)); inject a fake in tests.
    • onError? — handler-error sink (default console.error).
  • BroadcastBrokerOptions, BroadcastBroker<TMessage>, BroadcastChannelLike

Adapter properties

  • Capabilities: { patterns: true, replay: false, ordering: 'none' }. Pattern routing (*/#) is done locally on the receiving side. Cross-tab with multiple publishers has no shared clock → no ordering promise.
  • Local + remote in one publish. A BroadcastChannel never echoes to its own sender, so the relay fans a publish out to local subscribers AND posts it to the channel — every tab including the originator hears it, exactly once.
  • Structured clone. Messages must be structured-cloneable (DomainEvents are). A non-cloneable payload throws at postMessage.
  • Foreign messages ignored. Only broker-tagged envelopes are delivered; other traffic on the channel is skipped.
  • close() detaches the listener and closes the channel.

License

Apache License 2.0

Keywords

broker

FAQs

Package last updated on 30 Oct 2026

Related posts