Core Library0.xAPI Reference

Choose documentation 3

latest

Current version

latest
English

Early release libtmux is released, and its APIs may still change between releases. This site's structure and URLs may change too.

method libtmux-ts latest

TmuxEventStream.find

Resolve with the first event matches accepts, or undefined if the deadline passes or the stream is closed first.

Source and package
Qualified name
TmuxEventStream.find
Module
types
Declared in
TmuxEventStream
Package
libtmux
Source
packages/libtmux/src/types.ts
find<Match extends TmuxEvent>( matches: (event: TmuxEvent) => event is Match, options?: { readonly timeoutMs?: number }, ): Promise<Match | undefined>find( matches: (event: TmuxEvent) => unknown, options?: { readonly timeoutMs?: number }, ): Promise<TmuxEvent | undefined>

Description#

This consumes the stream, which is what iterating it does anyway. It exists because every caller otherwise writes the same loop, deadline, and cleanup, and forgetting the deadline turns a missed event into a hang.

Type parameters
Parameters
Raises
  • LibTmuxError – when the stream ends under the wait — the server went away, or the connection dropped. Closing it on purpose is not that: a caller cancelling, or a scope ending, answers undefined, because deciding to stop waiting is not a failure anyone should have to catch. Undefined therefore means the deadline passed or the wait was called off, and only the deadline says the workload really did not print what was waited for. timeoutMs, when set, must be a positive timer-safe integer. for find(matches, options) [overload 1]

Esc

Type to search.

Reference previewOpen reference