setTimeout
FunctionSets a timeout to call the provided callback after the specified number of milliseconds.
- Available on all platforms
Platform details: Snapchat, SPECS, Camera Kit Web, Camera Kit Mobile fully supported.
setTimeout(
code,delay):number
Sets a timeout to call the provided callback after the specified number of milliseconds. The callback is invoked on the scripting thread once the deadline has passed. Use clearTimeout with the returned TimeoutID to cancel a pending timeout before it fires.
Parameters
| Parameter | Type |
|---|---|
code | () => void |
delay | number |
Returns
number
TimeoutID that can be used to clear the timeout.
Example
const timeoutId = setTimeout(function() {
print("One second has passed.");
}, 1000);
// Cancel the timeout before it fires:
clearTimeout(timeoutId);