pub struct Interval { /* private fields */ }
Expand description

A scheduled interval.

See Interval::new for scheduling new intervals.

Once scheduled, you can either cancel so that it ceases to fire or forget it so that it is un-cancel-able.

Implementations

Schedule an interval to invoke callback every millis milliseconds.

Example
use gloo_timers::callback::Interval;

let interval = Interval::new(1_000, move || {
    // Do something...
});

Make this interval uncancel-able.

Returns the identifier returned by the original setInterval call, and therefore you can still cancel the interval by calling clearInterval directly (perhaps via web_sys::clear_interval_with_handle).

Example
use gloo_timers::callback::Interval;

// We want to do stuff every second, indefinitely.
Interval::new(1_000, || {
    // Do stuff...
}).forget();

Cancel this interval so that the callback is no longer periodically invoked.

The scheduled callback is returned.

Example
use gloo_timers::callback::Interval;

let interval = Interval::new(1_000, || {
    // Do stuff...
});

// If we don't want this interval to run anymore, then cancel it.
if nevermind() {
    interval.cancel();
}

Trait Implementations

Formats the value using the given formatter. Read more

Executes the destructor for this type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.