# io.github.libtmux.control.EventSubscription.onReady

- **Module:** io.github.libtmux.control
- **Package:** io.github.libtmux:libtmux
- **Language:** Java
- **Kind:** method
- **Source:** https://github.com/libtmux/libtmux-java/blob/f56392b5d9bc7f1f9c1631842333fb90f3d82d40/libtmux/src/main/java/io/github/libtmux/control/EventSubscription.java#L220
- **Page:** https://libtmux.org/en/java/latest/reference/io-github-libtmux-control-eventsubscription-eventsubscription-onready/

```
io.github.libtmux.control.EventSubscription.onReady(callback: Runnable) -> void
```

Arms a one-shot wakeup for when this subscription has something to read, or has ended.

Runs {@code callback} at once, on this thread, when a step is already waiting or the
subscription has ended. Otherwise it runs once, on the control client's reader thread, when the
first step arrives or the subscription ends, and is then disarmed: drain with {@link #poll()}
until it is empty, then arm again. Checking and arming happen under the lock that delivery
takes, so a step cannot slip between them unannounced.

The callback runs on the thread delivering events, so it must not block: resume a waiting
coroutine, complete a promise, and return. One that throws is logged and ignored, and delivery
continues.

## Raises

- [`IllegalStateException`](https://docs.oracle.com/en/java/javase/21/docs/api/java/lang/IllegalStateException.html): if a callback is already armed, or a stream or publisher owns this subscription
