pub fn run_app<P, A>(
config: WindowConfig,
presenter: P,
app: A,
) -> Result<(), EventLoopError>Expand description
Drive an App from the windowed event loop.
This is the inverted driver: winit owns the event loop and calls back
into the app on each redraw, rather than the app owning a while loop.
Each frame builds a Frame with a wall-clock
dt measured via web_time::Instant: a plain std::time::Instant
re-export on native, backed by the browser’s Performance.now() on
wasm32 (where std::time::Instant itself is unavailable). Calls
App::update.
On Flow::Exit the event loop exits gracefully
(via [ActiveEventLoop::exit]) instead of force-exiting the process, so
the stack unwinds normally and Drop impls up the call chain (unflushed
writes, GPU/surface teardown, app-level RAII) run before the process
exits. This works the same on wasm: winit’s web backend implements
ActiveEventLoop::exit by stopping its requestAnimationFrame-driven
runner rather than leaving it a no-op.
See run_windowed’s “Presenting is automatic” section: the app’s
update implementation no longer needs to call
Terminal::present itself here either, this driver presents automatically after each call,
except on Flow::Idle, where the present is skipped entirely
and the previous frame stays on screen.
§Resizing is not automatic
This driver does not resize the Terminal itself. On every window resize it pushes
Event::Resize with the new cell dimensions; the app must poll that event and call
Terminal::resize to resize the terminal’s own grid buffers.
§Errors
Returns [winit::error::EventLoopError] if the event loop cannot be
created or fails while running.