1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#![doc = include_str!("../README.md")]
pub mod executor;
use async_component_core::{AsyncComponent, context::StateContext};
use executor::{ExecutorPollEvent, WinitExecutor};
use winit::{
event::Event,
event_loop::{ControlFlow, EventLoop},
};
pub trait WinitComponent {
fn on_event(&mut self, event: &mut Event<()>, control_flow: &mut ControlFlow);
}
pub fn run<C: AsyncComponent + WinitComponent + 'static>(
event_loop: EventLoop<ExecutorPollEvent>,
func: impl FnOnce(&StateContext) -> C,
) -> ! {
let executor = WinitExecutor::new(event_loop);
executor.run(func)
}