import { Channel } from './channel'; import type { PipeTarget } from '../protocol/pipeable'; import { read } from '../protocol/pipeable'; /** * compose multiple channels into one * * @public */ export declare class ChannelHub implements PipeTarget { /** a helper function, equivalant to ChannelHub.constructor */ static from(writers?: Channel[], readers?: Channel[]): ChannelHub; private closed; private readers; private writers; constructor(writers?: Channel[], readers?: Channel[]); /** * send a value to the hub, will be received by all readers * @param T - value * @throws `Channel.ClosedChannelError` - if ChannelHub is closed */ broadcast(value: T): void; /** * get a reader channel that can get messages from channel hub * * use {@link ChannelHub.disconnect} if you don't want to receive messages from the hub * @throws `Channel.ClosedChannelError` - if ChannelHub is closed */ reader(): Channel; /** * get a writer channel that can send messages to channel hub * * use {@link ChannelHub.disconnect} if you don't want to send messages to the hub * @throws `Channel.ClosedChannelError` - if ChannelHub is closed */ writer(): Channel; /** * diconnect a channel from the hub, could be a reader or a writer * * disconnected channel will NOT be closed automatically, * they can still be used to send and receive messages */ disconnect(ch: Channel): void; /** * @internal */ [read](value: T): void; /** * close the hub and all readers/writers connected to it * * no-op if already closed */ close(): void; } //# sourceMappingURL=channel_hub.d.ts.map