Home > widget-integration > CountdownTimerController > renderAndStartTick

CountdownTimerController.renderAndStartTick() method

Perform the initial tick and start the 1-second interval loop.

Called once after a campaign is successfully fetched. Runs the first tick() synchronously (to avoid a 1s blank flash), then sets up setInterval for subsequent ticks.

Signature:

protected renderAndStartTick(): Promise<void>;

Returns:

Promise<void>

Example

Override to use requestAnimationFrame for smoother updates:

protected async renderAndStartTick() {
  await this.tick();
  if (!this.element) return;
  const loop = () => { this.tick(); this.intervalId = requestAnimationFrame(loop); };
  this.intervalId = requestAnimationFrame(loop);
}