interface Channel.Read<T>
A read-only Channel that can perform blocking reads. This means that a receive
call will block until a message is available.
Extends: AsyncStreamable<T>
Implemented by: CrossChannel<TSend,TReceive>
, Channel<T>
Type parameters
Name | Default | Description |
---|---|---|
T | void | the channel message type |
Properties
capacity
The maximum amount of messages the Channel can buffer. If 0, the channel is unbuffered and the communication is synchronous.
capacity
Definition
get capacity(): number;
isExhausted
Returns true if the channel is closed and there are no message in the buffer (length = 0), false otherwise.
isExhausted
Definition
get isExhausted(): boolean;
Methods
asyncStream
Returns an asynchronous stream of values.
asyncStream
readable
Returns the Channel as a readonly Channel.Read instance.
readable
Definition
readable():
Channel.Read
<T>;
receive
Returns the next message sent to the Channel. Blocks if there are no messages.
receive
Definitions
receive<RT>(options: {
signal?: AbortSignal
|
undefined;
timeoutMs?: number
|
undefined;
recover: (channelError:
Channel.Error
) => RT;
}): Promise<T
|
RT>;
receive(options?: {
signal?: AbortSignal
|
undefined;
timeoutMs?: number
|
undefined;
recover?: undefined;
}): Promise<T>;
Type parameters
Name | Description |
---|---|
RT |
Parameters
Name | Type | Description |
---|---|---|
options | { signal?: AbortSignal | undefined; timeoutMs?: number | undefined; recover: (channelError: Channel.Error ) => RT; } | (optional) the options to receive a message - signal: (optional) an abort signal to cancel receiving - timeoutMs: (optional) amount of milliseconds to wait for received message - recover: (optional) a function that can be supplied to recover from a channel error |