pub fn run<'a, C, F>(entry: F)Expand description
Runs the platform-specific event loop with the given entry component.
This function initializes and starts the appropriate event loop for the current platform:
- Windows: Uses Win32 message loop with PeekMessage for non-blocking message processing
- macOS: Uses NSApplication with NSRunLoop and NSTimer for periodic runtime polling
- iOS: Uses NSRunLoop with NSTimer for periodic runtime polling (without NSApplication)
The function creates a Compo runtime, spawns the entry component as an async task, and integrates with the platform’s native event loop to ensure proper execution of async components.
§Type Parameters
C- The component type that implementsComponent<'a>F- The async function type that takes aWeak<C>and returns a future
§Arguments
entry- The entry point async function that will be executed as the root component
§Platform-specific behavior
- Windows: Registers a message handler and runs the Loop with Windows message processing
- macOS: Creates NSApplication, sets up a timer for runtime polling, and runs the app loop
- iOS: Sets up NSRunLoop with a timer for runtime polling (suitable for iOS apps)
§Examples
//! Platform-specific event loop implementations for the Compo framework.
//!
//! This module provides cross-platform event loop integration that allows Compo
//! applications to run natively on different operating systems. Each platform
//! uses its native event loop mechanism:
//!
//! - **Windows**: Win32 message loop with PeekMessage for non-blocking processing
//! - **macOS**: NSApplication with NSRunLoop and NSTimer for periodic polling
//! - **iOS**: NSRunLoop with NSTimer for periodic polling (without NSApplication)
//! - **Android**: JNI integration with Java MainLoop for Android event system
//!
//! The module exports platform-appropriate `run` functions that initialize the
//! Compo runtime and integrate it with the platform's native event loop.
use compo::prelude::*;
use compo_platform_loop::prelude::run;
#[component]
async fn app() {
println!("Hello from Compo!");
}
fn main() {
run(app);
}