use iced::futures; pub fn every( duration: std::time::Duration, ) -> iced::Subscription { iced::Subscription::from_recipe(Every(duration)) } struct Every(std::time::Duration); impl iced_native::subscription::Recipe for Every where H: std::hash::Hasher, { type Output = std::time::Instant; fn hash(&self, state: &mut H) { use std::hash::Hash; std::any::TypeId::of::().hash(state); self.0.hash(state); } fn stream( self: Box, _input: futures::stream::BoxStream<'static, I>, ) -> futures::stream::BoxStream<'static, Self::Output> { use futures::stream::StreamExt; async_std::stream::interval(self.0) .map(|_| std::time::Instant::now()) .boxed() } }