[−][src]Struct gloo_timers::callback::Timeout
A scheduled timeout.
See Timeout::new
for scheduling new timeouts.
Once scheduled, you can either cancel
so that it doesn't run or forget
it so that it is un-cancel-able.
Methods
impl Timeout
[src]
pub fn new<F>(millis: u32, callback: F) -> Timeout where
F: 'static + FnOnce(),
[src]
F: 'static + FnOnce(),
Schedule a timeout to invoke callback
in millis
milliseconds from
now.
Example
use gloo_timers::callback::Timeout; let timeout = Timeout::new(1_000, move || { // Do something... });
pub fn forget(self) -> i32
[src]
Make this timeout uncancel-able.
Returns the identifier returned by the original setTimeout
call, and
therefore you can still cancel the timeout by calling clearTimeout
directly (perhaps via web_sys::clear_timeout_with_handle
).
Example
use gloo_timers::callback::Timeout; // We definitely want to do stuff, and aren't going to ever cancel this // timeout. Timeout::new(1_000, || { // Do stuff... }).forget();
pub fn cancel(self) -> Closure<dyn FnMut()>
[src]
Cancel this timeout so that the callback is not invoked after the time is up.
The scheduled callback is returned.
Example
use gloo_timers::callback::Timeout; let timeout = Timeout::new(1_000, || { // Do stuff... }); // If actually we didn't want to set a timer, then cancel it. if nevermind() { timeout.cancel(); }
Trait Implementations
Auto Trait Implementations
impl !Send for Timeout
impl !Sync for Timeout
impl Unpin for Timeout
impl !RefUnwindSafe for Timeout
impl !UnwindSafe for Timeout
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> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,