Skip to content

delay

The delay hook provides a way to create a function that will run a callback after a specified number of milliseconds of ticker time.

It ensures that the delay is in sync with the shared ticker’s time units, making it ideal for animations or syncing with other actions based on ticker time.

The delay is synchronized with the shared ticker, so it will not progress if the ticker is paused or stopped.

This hook must be called within a SolidJS tracking scope, such as a component or another hook, that is a descendant of PixiApplication or TickerProvider.

Note This function cannot be used in an async context because the Application and Ticker context providers aren’t available. For that purpose you should use the alternative createAsyncDelay hook.

import { delay, 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 you need to delay execution in a way that is synchronized with the ticker.
  • For animations or other operations that depend on the ticker’s timing.
  • To avoid using external time measurements like setTimeout in ticker-dependent contexts.