Skip to main content

every

Function every 

Source
pub fn every(period: Duration, fun: impl FnMut() + 'static) -> TimerHandle
Expand description

Runs fun every period on the app’s clock, until the returned handle is dropped or the creating owner is cleaned up.

The first run comes one period after the timer was created. A timer that falls behind fires once per frame and reschedules from the current time, so a zero period behaves as a request to run once per frame, and every frame with a due timer keeps the app awake. Keep the handle alive for as long as the timer should run; see TimerHandle. When no timer can be created, the handle that comes back is inert and cancels nothing.