Utils
Helps RPC protocol services buffer messages until their receive loop starts.
Client and server protocol constructors use these helpers to expose a stable service before the active receiver is installed. Writes made before run starts are buffered with their current Context, then replayed once the receiver is ready.
Services
Signature
declare function withRun<
A extends {
readonly run: (f: (...args: Array<any>) => Effect<void>) => Effect<never>;
},
>(): <EX, RX>(
f: (write: Parameters<A["run"]>[0]) => Effect<Omit<A, "run">, EX, RX>,
) => Effect<A, EX, RX>;withRunClient
Added in v4.0.0
Source
Builds an RPC client protocol service that tracks active client IDs and buffers server responses per client until that client's run handler is installed.
Signature
declare function withRunClient<EX, RX>(f: (write: (clientId: number, response: FromServerEncoded) => Effect<void>, clientIds: ReadonlySet<number>) => Effect<Omit<{
readonly run: (clientId: number, f: (data: FromServerEncoded) => Effect<void>) => Effect<never>;
readonly send: (clientId: number, request: FromClientEncoded, transferables?: readonly Array<Transferable>) => Effect<void, RpcClientError>;
readonly supportsAck: boolean;
readonly supportsTransferables: boolean;
}, "run">, EX, RX>): Effect<{
readonly run: (clientId: number, f: (data: FromServerEncoded) => Effect<void>) => Effect<never>;
readonly send: (clientId: number, request: FromClientEncoded, transferables?: readonly Array<Transferable>) => Effect<void, RpcClientError>;
readonly supportsAck: boolean;
readonly supportsTransferables: boolean;
}, EX, RX>
Builds a service with a
runmethod that buffers writes untilruninstalls a writer, replays buffered writes with their original contexts, and restores the previous writer when the run ends.