Skip to main content
Module

x/rimbu/channel/mod.ts>Channel.Constructors

Rimbu is a TypeScript library focused on immutable, performant, and type-safe collections and other tools.
Go to Latest
interface Channel.Constructors
import { type Channel } from "https://deno.land/x/rimbu@1.0.2/channel/mod.ts";
const { Constructors } = Channel;

Defines the static Channel API.

Properties

select: { <CS extends Channel.Read<any>[], RT>(channels: CS, options: { signal?: AbortSignal | undefined; timeoutMs?: number | undefined; recover: (channelError: Channel.Error) => RT; }): Promise<RT | [K in keyof CS]: Channel.MessageType<CS[K]>[number]>; <CS extends Channel.Read<any>[]>(channels: CS, options?: { signal?: AbortSignal | undefined; timeoutMs?: number | undefined; recover?: undefined; }): Promise<[K in keyof CS]: Channel.MessageType<CS[K]>[number]>; }

Resolves, from the given channel array, to the channel value that is received first, taking into account the provided options.

selectMap: { <TS extends any[], HS extends [K in keyof TS]: [Channel.Read<TS[K]>, (value: TS[K]) => any]>(options?: { signal?: AbortSignal | undefined; timeoutMs?: number | undefined; recover?: undefined; }, ...cases: HS & [K in keyof TS]: [Channel.Read<TS[K]>, (value: TS[K]) => any]): Promise<[K in keyof HS]: Promise<ReturnType<HS[K][1]>>[number]>; <TS extends any[], HS extends [K in keyof TS]: [Channel.Read<TS[K]>, (value: TS[K]) => any], RT>(options: { signal?: AbortSignal | undefined; timeoutMs?: number | undefined; recover: (channelError: Channel.Error) => RT; }, ...cases: HS & [K in keyof TS]: [Channel.Read<TS[K]>, (value: TS[K]) => any]): Promise<[K in keyof HS]: Promise<ReturnType<HS[K][1]>>[number] | RT>; }

Resolves, from the given tuples of channels and channel value handlers, the result of applying the corresponding channel handler to the first channel value that is received. options.

Methods

getter
Error(): ChannelError

The types of possible Channel errors.

create<T = void>(options?: Channel.Config): Channel<T>

Returns a new Channel instance that can be used to synchronize asynchronous processes within a single thread.