Skip to main content

Module wait

Module wait 

Source
Expand description

Waiting on the application: until a journal event matches, or until the application is settled. The bridge.wait capability and the test kit’s frame-stepping wait (egui_pop_test::wait::wait_until) share it.

Experimental: may change in any release (docs/stability.md).

The check never blocks: AppHandle::wait_met says whether the condition holds now. Who waits holds the call and checks again after each frame until it holds or a deadline passes: a kittest harness steps frames, a transport re-checks on the UI thread. The UI thread itself never sleeps on it.

use egui_pop_api::about::{AboutPlugin, AppInfo};
use egui_pop_api::{App, DefaultPlugins};
use egui_pop_api::wait::{WaitFor, Waited};
use serde_json::json;

let mut app = App::builder()
    .plugins(DefaultPlugins)
    .plugin(AboutPlugin::new(AppInfo::new("Demo", "1.0.0")))
    .build(&egui::Context::default())
    .unwrap();
let since = app.handle().last_event();
let f = app.debug_call("commands", "run", &json!({ "id": "about.read" }));
assert!(f.ok, "{}", f.message);
let done = app.handle().wait_met(&WaitFor::event("command.done"), since);
assert!(matches!(done, Some(Waited::Event(e)) if e.data["command"] == "about.read"));
// The same through the bridge, as an agent asks it.
let f = app.debug_call(
    "bridge",
    "wait",
    &json!({ "event": "command.done", "since": since }),
);
assert_eq!(f.data["met"], true);

Enums§

WaitFor
What a wait waits for.
Waited
What ended a wait.

Functions§

args_schema
The JSON Schema of bridge.wait’s arguments.
result_schema
The JSON Schema of bridge.wait’s result.