AbstractStaticrunFunction to execute after the delay.
Delay in Ticks (20 ticks = 1 second).
OptionalprofileLabel: stringOptional profiling label. If provided, the callback is wrapped with DebugTimerUtil.start / DebugTimerUtil.stop.
The timeout ID from system.runTimeout, or undefined if validation fails.
// Run once after 40 ticks (2 seconds)
TimerUtil.runTimeout(() => doSomethingOnce(), 40);
// Run once after 20 ticks with profiling
TimerUtil.runTimeout(() => showcaseProfiling(), 20, "showcaseProfiling.once");
profileLabel is provided, the callback is wrapped with
DebugTimerUtil.start / DebugTimerUtil.stop.undefined (and logs an error) if callback is not a function
or delay is not a positive number.StaticrunRepeats a callback every delay ticks.
options.name to allow later control via TimerUtil.clear,
statistics via TimerUtil.getNamedIntervalStats, and to prevent accidental duplicates.options.name. Useful for quick, fire-and-forget repeating work.Function to execute each interval.
Period in Ticks (20 ticks = 1 second).
See NamedIntervalOptions and IntervalOptions.
The interval ID from system.runInterval, or undefined if validation fails
or if a named interval already exists and force is not set.
// Anonymous interval, every 20 ticks
const id = TimerUtil.runInterval(() => everySecondThisRuns(), 20);
// Named interval with profiling and an immediate first run
TimerUtil.runInterval(() => refreshStats(), 10, {
name: "StatsRefresh",
beginImmediately: true,
profile: true, // uses name as profile label
});
// Replace an existing named interval
TimerUtil.runInterval(() => rescan(), 5, { name: "Scanner", force: true, profile: "scanner" });
beginImmediately is true, the callback runs once before scheduling.options.profile:
true → uses the interval's name (or "anonymous_interval" for anonymous).string → uses the provided label.force: true logs an error and returns undefined.undefined if callback is not a function or delay is not a positive number.Repeats a callback every delay ticks.
options.name to allow later control via TimerUtil.clear,
statistics via TimerUtil.getNamedIntervalStats, and to prevent accidental duplicates.options.name. Useful for quick, fire-and-forget repeating work.Function to execute each interval.
Period in Ticks (20 ticks = 1 second).
Optionaloptions: IntervalOptionsSee NamedIntervalOptions and IntervalOptions.
The interval ID from system.runInterval, or undefined if validation fails
or if a named interval already exists and force is not set.
// Anonymous interval, every 20 ticks
const id = TimerUtil.runInterval(() => everySecondThisRuns(), 20);
// Named interval with profiling and an immediate first run
TimerUtil.runInterval(() => refreshStats(), 10, {
name: "StatsRefresh",
beginImmediately: true,
profile: true, // uses name as profile label
});
// Replace an existing named interval
TimerUtil.runInterval(() => rescan(), 5, { name: "Scanner", force: true, profile: "scanner" });
beginImmediately is true, the callback runs once before scheduling.options.profile:
true → uses the interval's name (or "anonymous_interval" for anonymous).string → uses the provided label.force: true logs an error and returns undefined.undefined if callback is not a function or delay is not a positive number.StaticnextSchedule a callback on the next tick.
Function to run next tick.
OptionalprofileLabel: stringOptional profiling label. Wraps the callback with DebugTimerUtil.start / DebugTimerUtil.stop.
The ID from system.run, or undefined if validation fails.
profileLabel is provided, the callback is wrapped with
DebugTimerUtil.start / DebugTimerUtil.stop.undefined if callback is not a function.StaticclearClear a scheduled interval by name (named intervals) or by ID (anonymous or named).
The interval ID (from runInterval) or the name provided in NamedIntervalOptions.
// Clear by ID
const id = TimerUtil.runInterval(() => tick(), 20);
if (id) TimerUtil.clear(id);
// Clear by name
TimerUtil.runInterval(() => refresh(), 10, { name: "StatsRefresh" });
TimerUtil.clear("StatsRefresh");
string is passed, it is treated as the name of a named interval.number is passed, it is treated as the interval ID returned by runInterval.StaticclearClear all currently active named intervals.
name in NamedIntervalOptions.StaticgetGet rolling performance statistics for a named interval.
The interval name used when creating it.
NamedIntervalStats with averageTime and maxTime (ms) computed
over the recent execution window, or undefined if no such interval exists.
StaticlistList the names of all active named intervals.
An array of names corresponding to active named intervals.
Schedule a one-off callback after a specified delay (in ticks).