pub fn use_timeout_fn<CbFn, Arg, D>(
callback: CbFn,
delay: D,
) -> UseTimeoutFnReturn<impl Fn(Arg) + Clone, Arg, impl Fn() + Clone>
Expand description
Wrapper for setTimeout
with controls.
§Demo
§Usage
let UseTimeoutFnReturn { start, stop, is_pending, .. } = use_timeout_fn(
|i: i32| {
// do sth
},
3000.0
);
start(3);
§Server-Side Rendering
On the server the callback will never be run. The returned functions are all no-ops and
is_pending
will always be false
.