Embedded App
EmbeddedApp drives the runtime without the full platform event loop. Use it for embedding zero-native in an existing application, game engine, or custom render loop.
Usage
var embedded = zero_native.embed.EmbeddedApp.init(my_app.app(), my_platform);
try embedded.start();
// In your render loop:
try embedded.frame();
// On resize:
try embedded.resize(new_surface);
// On shutdown:
try embedded.stop();Methods
| Method | Description |
|---|---|
init(app, platform) | Create an embedded app with a runtime |
start() | Dispatch app_start event, loads the WebView source |
resize(surface) | Dispatch surface_resized event |
frame() | Dispatch frame_requested event |
stop() | Dispatch app_shutdown event |
How it works
EmbeddedApp wraps a Runtime and an App. Each method dispatches a platform event via runtime.dispatchPlatformEvent, giving you full control over the event loop while still using zero-native's runtime, bridge, and window management.
Mobile examples
The repository includes full mobile host examples:
examples/ios- Xcode project with a SwiftUIViewController,WKWebView, andzero_native.hbridge.examples/android- Gradle/Kotlin project with JNI and CMake wiring forlibzero-native.a.
Both examples expect a local libzero-native.a built from the repository and copied into the path documented in each example README.
Testing with EmbeddedApp
var null_platform = zero_native.NullPlatform.init(.{});
var state: u8 = 0;
var embedded = zero_native.embed.EmbeddedApp.init(.{
.context = &state,
.name = "embedded",
.source = zero_native.WebViewSource.html("<p>Embedded</p>"),
}, null_platform.platform());
try embedded.start();
// null_platform.loaded_source now contains the loaded HTML