Private
Readonly
channelReadonly
defaultThe default topic to publish to.
Private
keepPrivate
Readonly
keepalivePrivate
Readonly
nowPrivate
onWraps 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.
Rest
...args: [topic: string, event: MessageEvent<unknown>]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
Readonly
peerThis peer's ID.
Private
Optional
peerPrivate
Readonly
peerPrivate
Readonly
topicPrivate
Readonly
topicRegisters an event handler of a specific event type.
Dispatches a message.
Optional
options: MessageOptionsDispatches the event
to the list of handlers for event.type
.
false
if event is cancelled; true
otherwise.
Private
keepalivePrivate
onPrivate
onRemoves an event listener.
Subscribes to new messages and returns a handle to unsubscribe.
Optional
options: PeerAwareSubscribeOptions<Msg, PeerId>Returns the list of peers that are subscribed to a topic.
Optional
options: MessageOptionsGenerated using TypeDoc
PeerAwareMessageBus implementation using browser BroadcastChannel.