delay
The delay function runs a callback after a specified number of milliseconds of ticker time.
The delay synchronizes with the ticker from the nearest context provider. Use it for animations or other operations that depend on the ticker timing.
Call this function within a SolidJS tracking scope. This scope must be a descendant of PixiApplicationProvider, PixiCanvas, or TickerProvider.
import { delay } from "pixi-solid/utils";import { Text } from "pixi-solid";
const DelayedCallbackComponent = () => { const handlePointerDown = () => { console.log("Pointer down"); delay(1000, () => { console.log("1 second has passed on the ticker"); }); };
return <Text text={"Click me"} onpointerdown={handlePointerDown} />;};When to use it
Section titled “When to use it”- When you need to delay execution that synchronizes with the ticker.
- For animations or other operations that depend on the ticker timing.
- To replace external time measurements such as
setTimeoutin ticker-dependent contexts.