I am trying to run a function at the end of a delay if the timer is not canceled. The use case is a press and hold / double tap for user input.
The main issue that I am having is that the tokio::run(task);
stops the main loop from executing thus prevents me from evaluating the state of the users control.
fn start_timer(&self) {
let function_name = self.combo.function_name.clone();
let when = Instant::now() + Duration::from_millis(self.combo.timer_value as u64);
let task = Delay::new(when)
.and_then(move |_| {
call_function(&function_name, InteropParams::Button);
Ok(())
})
.map_err(|e| panic!("delay errored; err={:?}", e));
tokio::run(task);
}