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

Server.withConnection

Run body against a connected server, closing it afterwards.

Source and package
Qualified name
Server.withConnection
Module
server
Declared in
Server
Package
libtmux
Source
packages/libtmux/src/server.ts
async withConnection<T>( body: (live: ConnectedServer) => Promise<T>, options?: ConnectOptions, ): Promise<T>

Description#

The scoped form of connect(), for code that cannot use await using — it needs Symbol.asyncDispose in the consumer's lib — or would rather not manage the lifetime by hand. The connection closes on the way out whether body returns or throws.

Examples#

const opened = await server.withConnection(async (live) => {
await session.newWindow({ name: "build" });
return live.waitFor((current) => current.windows.exists({ name: "build" }));
});
opened.windows.count({ name: "build" }); // 1
Type parameters
Parameters
Esc

Type to search.

Reference previewOpen reference