useInterval
function useInterval<S>(
scope: Fusion.Scope<S & typeof(Fusion)>,
delay: Fusion.UsedAs<number?>,
callback: (Fusion.Scope<S>) -> (),
immediate: boolean?
)
Sets an interval that runs the callback function every delay
seconds. If delay
is undefined
, the interval is cleared. If the delay changes, the the interval is cleared. If the delay changes, the interval is reset.
Parameters
scope : Fusion.Scope<S & typeof(Fusion)>
The scope to store cleanup tasks.
delay : Fusion.UsedAs<number?>
The delay, in seconds per each interval.
callback : (Fusion.Scope<S>) -> ()
The callback to run at an interval. Receives an inner scope that is cleaned up per each interval.
immediate : boolean?
Whether to spawn the callback immediately.
Example Usage
-- TODO: write example