Skip to main content

interface Channel.Write<T>

A write-only Channel that can perform blocking writes. This means that a send call will block until the channel has capacity to send a message.

Implemented by: CrossChannel<TSend,TReceive>, Channel<T>

Type parameters

NameDefaultDescription
Tvoidthe channel message type

Properties

isClosed

Returns true if the Channel is closed.

Definition

get isClosed(): boolean;

Methods

close

Closes the channel. After a close, further send actions will throw.

Definition

close(): void;

send

Send the given value message to the Channel. Blocks if the Channel is already at maximum capacity.

Definitions

send(value: T, options: {
      signal?: AbortSignal | undefined;
      timeoutMs?: number | undefined;
      catchChannelErrors?: false | undefined;
    }): Promise<void>;

send(value: T, options?: {
      signal?: AbortSignal | undefined;
      timeoutMs?: number | undefined;
      catchChannelErrors: boolean;
    }): Promise<undefined | Channel.Error>;

Parameters

NameTypeDescription
valueTthe message to send to the channel
options{
      signal?: AbortSignal | undefined;
      timeoutMs?: number | undefined;
      catchChannelErrors?: false | undefined;
    }
(optional) the message send options
- signal: (optional) an abort signal to cancel sending
- timeoutMs: (optional) amount of milliseconds to wait for being able to send message
- recover: (optional) a function that can be supplied to recover from a channel error

sendAll

Sequentially send all the values in the given source to the channel. Blocks until all the values are sent.

Definitions

sendAll(source: AsyncStreamSource<T>, options: {
      signal?: AbortSignal | undefined;
      timeoutMs?: number | undefined;
      catchChannelErrors?: false | undefined;
    }): Promise<void>;

sendAll(source: AsyncStreamSource<T>, options?: {
      signal?: AbortSignal | undefined;
      timeoutMs?: number | undefined;
      catchChannelErrors: boolean;
    }): Promise<undefined | Channel.Error>;

Parameters

NameTypeDescription
sourceAsyncStreamSource<T>a stream source containing the values to send
options{
      signal?: AbortSignal | undefined;
      timeoutMs?: number | undefined;
      catchChannelErrors?: false | undefined;
    }
the message send options
- signal: (optional) an abort signal to cancel sending
- timeoutMs: (optional) amount of milliseconds to wait for being able to send message, for each separate message in the source
- recover: (optional) a function that can be supplied to recover from a channel error

writable

Returns the Channel as a write-only Channel.Write instance.

Definition

writable(): Channel.Write<T>;