[−][src]Struct gloo_timers::callback::Interval
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.
Methods
impl Interval
[src]
pub fn new<F>(millis: u32, callback: F) -> Interval where
F: 'static + FnMut(),
[src]
F: 'static + FnMut(),
Schedule an interval to invoke callback
every millis
milliseconds.
Example
use gloo_timers::callback::Interval; let interval = Interval::new(1_000, move || { // Do something... });
pub fn forget(self) -> i32
[src]
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();
pub fn cancel(self) -> Closure<dyn FnMut()>
[src]
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
Auto Trait Implementations
impl !Send for Interval
impl !Sync for Interval
impl Unpin for Interval
impl !UnwindSafe for Interval
impl !RefUnwindSafe for Interval
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,