Skip to main content

Type parameters

Name
T

Methods#

close#

â–¸ close(): void

Flushes the channel before notifying the consumer that the channel is closed (notification comes in the form of the async iterator returning). Further calls to e.g. send will throw a ChannelClosedError.

Returns: void

Defined in: channels/channel_interfaces.ts:23


fail#

â–¸ fail(error: Error): void

Behaves exactly like close, except throws an error in the consumer once the channel is flushed.

Parameters:#

NameType
errorError

Returns: void

Defined in: channels/channel_interfaces.ts:37


open#

â–¸ open(): void

Opens the channel. This is implicitly called at the start of send, close and fail as well, but can be called explicitly without having to write the channel.

Returns: void

Defined in: channels/channel_interfaces.ts:11


send#

â–¸ send(value: T): void

Sends data over the channel (buffering if the reader is busy).

Parameters:#

NameType
valueT

Returns: void

Defined in: channels/channel_interfaces.ts:16


sendAndClose#

â–¸ sendAndClose(value: T): void

A combination of send and close, but in one atomic operations. This is useful for queuing a message and immediately closing it, so that the events can be combined on the receiving end by checking isDone while consuming messages.

Parameters:#

NameType
valueT

Returns: void

Defined in: channels/channel_interfaces.ts:31