--- tags: zeta-dom --- Zeta DOM » [Disposables](/XigonPlaT-eWEEbN1jMglw) # Timers ### `setTimeout` Equivalent to `window.setTimeout`. ```typescript import { setTimeout } from "zeta-dom/util"; const dispose = setTimeout(() => { /* ... */ }); // somewhere else // calling clearTimeout under the hook dispose(); ``` ### `setInteval` Equivalent to `window.setInteval`. :::warning It is recommand to use `setIntevalSafe` for async operation. ::: ```typescript import { setInteval } from "zeta-dom/util"; const dispose = setInteval(() => { /* ... */ }, 1000); // somewhere else // calling clearInteval under the hook dispose(); ``` ### `setIntevalSafe` Like `window.setInteval`, but the next run is not scheduled until current operation completes. ```typescript import { setIntevalSafe } from "zeta-dom/util"; const dispose = setIntevalSafe(() => { return longOperationReturningPromise(); }, 1000); // somewhere else // calling clearTimeout under the hook dispose(); ```
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up