Server.liveState
A live, continuously rebuilt view of server , as a StateFlow .
Source and package
- Module
- io.github.libtmux.kotlin
- Declared in
- Server
- Package
- io.github.libtmux:libtmux-kotlin
- Source
- libtmux-kotlin/src/main/kotlin/io/github/libtmux/kotlin/LiveState.kt
- public 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 fun Server.liveState( session: Session, scope: Coroutine
Scope , attachTimeout: Duration = config.defaultTimeout ().toKotlin (), ): StateDuration Flow <ServerMirror >.View -
Description#
Wraps Java's
ServerMirrorrather than reinventing it: every routine case — resnapshot on notification, on gap, and on reconnect; conflation while a rebuild is in flight; ending oncesessionitself is gone — is already handled once, correctly, insideServerMirror. This function's only job is pumpingServerMirror.awaitNeweron a dedicated thread fromExecutionPolicy.streamReadsand publishing what comes back. NamedliveState, notServerMirror, so it does not collide with the Java type it wraps.scopeowns the returnedStateFlow's whole lifetime: closing the mirror is this function's ownlaunch+finally, tied toscope's cancellation, so the caller never has to close it by hand.- Parameters
-
-
session ( Session )
-
scope ( Coroutine
Scope ) -
attachTimeout ( Duration ) – how long to wait for the first attach, and the deadline each later rebuild wait uses to recheck
scopefor cancellation
-
- Raises
-
-
io
.github – synchronously if.libtmux .exception .Target Gone Exception session's server has already gone when this is called; later, the same failure endsscopeinstead, since it surfaces from the launched pump rather than from this call
-
Discussed in Coroutines and flows , Getting started