Class BroadcastChannelMessageBus<Msg, PeerId>

PeerAwareMessageBus implementation using browser BroadcastChannel.

Type Parameters

Hierarchy

Implements

Constructors

Properties

channel: BroadcastChannel
defaultTopic: string

The default topic to publish to.

keepAliveTimer: number = 0
keepaliveMs: number
now: (() => number)

Type declaration

    • (): number
    • Returns number

onMessage: ((...args) => MaybePromise<void>) = ...

Type declaration

    • (...args): MaybePromise<void>
    • Wraps a MaybePromise-yielding coroutine (generator function) into a function that returns MaybePromise. This allows you to use maybeAsync/yield in a similar way to async/await, where yield maybePromise will return awaited / resolved value.

      Parameters

      • Rest ...args: [topic: string, event: MessageEvent<unknown>]

      Returns MaybePromise<void>

      Example

      const add = maybeAsync(function* (a: number, b: number) {
      const result1: number = yield Promise.resolve(a); // result1 === a
      const result2 = yield b; // result2 === b
      return result + result2;
      });
      const result = await add(1, 2); // result === 3
peerId: PeerId

This peer's ID.

peerMonitor?: PeerSubscriptionMonitor<PeerId>
peerRefreshMs: number
topicHandlers: Map<string, PeerAwareMessageHandler<Msg, PeerId>[]> = ...
topicSubscribers: Map<string, Map<string, [peerId: PeerId, lastSeen: number]>> = ...

Methods

Generated using TypeDoc