Skip to main content
Module

x/async_channels/mod.ts>BroadcastChannel

Inspired by Go & Clojure Channels, async_channels provides channels as an asynchronous communication method between asynchronous functions.
Latest
class BroadcastChannel
implements SendCloser<TMsg>
import { BroadcastChannel } from "https://deno.land/x/async_channels@v1.0.0-rc8/mod.ts";

Constructors

new
BroadcastChannel(topicFn: (val: TMsg) => TTopic, options?: BroadcastChannelOptions)

Type Parameters

TMsg
TTopic

Properties

protected
readonly
options: BroadcastChannelOptions
protected
subscribers: Map<[TTopic, "topic"] | [TopicFn<TTopic>, "topicFn"], Set<SendCloser<TMsg>>>
readonly
isOpen

Methods

protected
doSubscribe(tuple: [TopicFn<TTopic>, "topicFn"] | [TTopic, "topic"], subOpts?: BroadcastSubscribeOptions): [Receiver<TMsg>, () => void]
debug(...args: unknown[])
error(...args: unknown[])
send(msg: TMsg, abortCtrl?: AbortController): Promise<void>
subscribe(topic: TTopic, subOpts?: BroadcastSubscribeOptions): [Receiver<TMsg>, () => void]
subscribeFn(topicFn: TopicFn<TTopic>, subOpts?: BroadcastSubscribeOptions): [Receiver<TMsg>, () => void]

Static Methods

from<TMsg, TTopic>(
input: Iterable<TMsg> | AsyncIterable<TMsg>,
topicFn: (val: TMsg) => TTopic,
): Subscribable<TMsg, TTopic>