Skip to content

Home > @unseenco/backstage-dataverse > Ticker

Ticker class

The Ticker class helps schedule callbacks. Scheduled callbacks are executed per tick. Ticks can be triggered by an external scheduling strategy, e.g. a raf.

Signature:

typescript
export default class Ticker

Constructors

ConstructorModifiersDescription
(constructor)(_conf)Constructs a new instance of the Ticker class

Properties

PropertyModifiersTypeDescription
__ticksnumber

Counts up for every tick executed. Internally, this is used to measure ticks per second.

This is "public" to TypeScript, because it's a tool for performance measurements. Consider this as experimental, and do not rely on it always being here in future releases.

dormantreadonlybooleanWhether the Ticker is dormant
timereadonlynumberThe time at the start of the current tick if there is a tick in progress, otherwise defaults to performance.now().

Methods

MethodModifiersDescription
offNextTick(fn)De-registers a fn to be called on the next tick.
offThisOrNextTick(fn)De-registers a fn to be called either on this tick or the next tick.
onNextTick(fn)Registers a side effect to be called on the next tick.
onThisOrNextTick(fn)

Registers for fn to be called either on this tick or the next tick.

If onThisOrNextTick() is called while Ticker.tick() is running, the side effect _will_ be called within the running tick. If you don't want this behavior, you can use onNextTick().

Note that fn will be added to a Set(). Which means, if you call onThisOrNextTick(fn) with the same fn twice in a single tick, it'll only run once.

tick(t)Triggers a tick which starts executing the callbacks scheduled for this tick.