Core LibraryAPI Reference

Choose documentation 1

latest

Current version

latest
English

Prerelease This site documents an alpha of libtmux. Its structure, URLs and APIs are subject to change.

method libtmux-kotlin latest

ControlClient.output

Package io.github.libtmux.kotlin.ControlClient.output io.github.libtmux.kotlin

Terminal output tmux pushes, as a cold Flow .

View as Markdown

Source and package
Module
io.github.libtmux.kotlin
Declared in
ControlClient
Package
io.github.libtmux:libtmux-kotlin
Source
libtmux-kotlin/src/main/kotlin/io/github/libtmux/kotlin/ControlClient.kt
public fun output(capacity: Int, onSubscribed: Kotlin suspending functions Allows a function to call suspending operations and pause without blocking a thread. It does not start a coroutine by itself. Language documentation () -> Unit = {}): Flow<Delivery<PaneOutput>>
method [source]

Description#

A fresh Java subscription opens per kotlinx.coroutines.flow.Flow.collect and closes when collection ends, cancels, or throws — fan-out means collecting twice, each with its own gap accounting. Not suspend : opening the subscription is local and does no tmux round trip: only collecting it reads.

Output tmux sends before the subscription opens is not delivered, and a cold flow opens it only when collection starts. So a command whose output is wanted belongs in onSubscribed , which runs once the subscription exists and before the first read, rather than before collect: control.output(32) { control.send("send-keys", ...) }.

Parameters
  • capacity ( Int )

  • onSubscribed ( Kotlin suspending functions Allows a function to call suspending operations and pause without blocking a thread. It does not start a coroutine by itself. Language documentation )

Discussed in Coroutines and flows , Getting started

Esc

Type to search.