use context::prelude::*; use std::{sync::Arc, thread}; use anyhow::Result; pub struct LoadingScreen; impl LoadingScreen { pub fn load( context: &Arc, gui: Option>, loader: L, on_ready: R, ) -> Result<()> where R: Fn(T) -> Result<()> + Send + Sync + 'static, T: Send + Sync + 'static, L: FnOnce() -> T + Send + Sync + 'static, G: TopLevelGui + TopGui + Send + Sync + 'static, { if let Some(gui) = &gui { gui.enable()?; } let context = context.clone(); thread::spawn(move || { let result = loader(); if let Some(gui) = &gui { gui.disable().unwrap(); } todo!(); // context.push_event(move || (on_ready)(result)); }); Ok(()) } }