TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/Augani/kael/llms.txt
Use this file to discover all available pages before exploring further.
Application type is your entry point into Kael. You construct it once in main, configure it with assets and an HTTP client, then call .run() to hand control to the platform event loop. Inside the run callback — and anywhere you hold a &mut App — you can open windows, manage type-keyed global state, register lifecycle observers, and spawn background tasks.
Application
Application is a thin wrapper around an Rc<AppCell>. You interact with it only during initial setup; all ongoing work happens through App.
Constructors
Creates a standard GUI application using the current platform backend. Assets default to an empty source and the HTTP client is a no-op stub. Prefer this in all normal cases.
Creates an application that will not open any windows. Useful for running Kael in SSH sessions or server contexts where a display is unavailable.
Builder methods
These methods return&Self so they can be chained before calling .run().
Registers a custom asset source used for loading images, SVGs, and other bundled resources.
Replaces the default no-op HTTP client with a real implementation. Required for any code that makes network requests through Kael’s HTTP layer.
Registers a handler that fires when the platform asks the application to open one or more URLs in bulk.
Registers a handler that fires once per URL when the platform asks the application to open it.
Registers a handler scoped to a specific URL scheme (e.g.
"myapp"). Only URLs whose scheme matches will invoke this handler.Invoked when an already-running application is relaunched, for example by double-clicking its dock icon on macOS. Commonly used to re-open the main window.
Starting the application
run blocks until the application quits. The callback receives a &mut App and is called exactly once, after the platform’s event loop is ready. This is where you open your first window.
App
App is the authoritative owner of all entity state, windows, and globals. You receive a &mut App inside .run() and in every event and observer callback.
Opening windows
&mut Window and &mut App and must return an Entity<V> that becomes the root view. The window draws at least one frame before open_window returns.
Reading and updating windows
update_window provides mutable access to the window’s root view and its Window. read_window provides read-only access. Both return Err if the window has been closed.
Quitting
on_app_quit run first (up to SHUTDOWN_TIMEOUT, which is 100 ms) before the process exits.
Global state
Globals are type-keyed singletons stored onApp. Any type that implements Global can be stored and retrieved by its TypeId. This is the idiomatic way to share cross-cutting state (settings, registries, service handles) without passing it through every call chain.
Accessing a global that has not been set will panic. Use
has_global or try_global when the global may be absent.Setting and reading
BorrowAppContext trait helpers
Any context that implements BorrowMut<App> — which includes App, Context<T>, and async contexts — also implements BorrowAppContext, which adds three convenience methods:
Stores a value as the global for type
G. Notifies any observers registered via observe_global.Leases the global mutably, calls the closure, then restores it. The closure receives both the global and the context, allowing you to open windows or mutate entities while holding the global.
Like
update_global, but creates a Default value first if the global is not yet set.Observing global changes
G is mutated. The returned Subscription must be held alive; dropping it unregisters the observer.
Lifecycle hooks
on_app_quit
SHUTDOWN_TIMEOUT (100 ms). Use this for flushing writes, releasing locks, or sending a final analytics event.
on_window_closed
on_app_restart
on_app_quit callbacks when the application is about to restart. Use it to persist state that must survive the restart.
Executors
BackgroundExecutor spawns futures on a thread pool. ForegroundExecutor runs futures on the main thread, interleaved with the event loop. Both are cloneable and can be stored for use in async code.