Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/rimbu/channel/custom/index.ts>Channel.Read

Rimbu is a TypeScript library focused on immutable, performant, and type-safe collections and other tools.
Go to Latest
interface Channel.Read
implements AsyncIterable<T>, AsyncStreamable<T>
import { type Channel } from "https://deno.land/x/rimbu@1.1.0/channel/custom/index.ts";
const { Read } = Channel;

A read-only Channel that can perform blocking reads. This means that a receive call will block until a message is available.

Type Parameters

optional
T = void

Methods

getter
capacity(): number

The maximum amount of messages the Channel can buffer. If 0, the channel is unbuffered and the communication is synchronous.

getter
length(): number

The amount of messages currently in the read buffer.

getter
isExhausted(): boolean

Returns true if the channel is closed and there are no message in the buffer (length = 0), false otherwise.

readable(): Channel.Read<T>

Returns the Channel as a readonly Channel.Read instance.

receive<RT>(options: { signal?: AbortSignal | undefined; timeoutMs?: number | undefined; recover: (channelError: Channel.Error) => RT; }): Promise<T | RT>

Returns the next message sent to the Channel. Blocks if there are no messages.

receive(options?: { signal?: AbortSignal | undefined; timeoutMs?: number | undefined; recover?: undefined; }): Promise<T>