use std::time::Duration;
use smithay_client_toolkit::reexports::calloop::{
EventLoop,
timer::{TimeoutAction, Timer},
};
struct ForgeState;
pub struct Forge(EventLoop<'static, ForgeState>);
impl Default for Forge {
fn default() -> Self {
let event_loop: EventLoop<'static, ForgeState> =
EventLoop::try_new().expect("Failed to initialize the event loop!");
Forge(event_loop)
}
}
impl Forge {
pub fn add_event<F: FnMut() + Send + 'static>(&self, duration: Duration, mut callback: F) {
self.0
.handle()
.insert_source(Timer::from_duration(duration), move |_, _, _| {
callback();
TimeoutAction::ToDuration(duration)
})
.unwrap();
}
}