Home > widget-integration > CountdownTimerModule

CountdownTimerModule class

Module for the countdown timer widget.

Registers CountdownTimerAPI, CountdownTimerController, and as providers and listens for countdownTimer TAE blocks to bootstrap a controller per block instance.

Signature:

export declare class CountdownTimerModule 

Example

Override to add analytics when a timer block initialises:

window.boostWidgetIntegration.extend('CountdownTimerModule', (CountdownTimerModule) => {
  return class extends CountdownTimerModule {
    async onInitBlock(block) {
      this.trackTimerInit(block.id);
      return super.onInitBlock(block);
    }
  };
});

Constructors

Constructor

Modifiers

Description

(constructor)(moduleRef, appService)

Constructs a new instance of the CountdownTimerModule class

Properties

Property

Modifiers

Type

Description

appService

protected

AppService

cartDrawerClosedHandler

protected

readonly

() => void

Bound handler for the boost-sd-cart-drawer-closed event.

Arrow function to preserve this context when used as an event listener. Destroys the active cart drawer timer controller.

cartDrawerController

protected

CountdownTimerController | null

cartDrawerOpenedHandler

protected

readonly

() => void

Bound handler for the boost-sd-cart-drawer-opened event.

Arrow function to preserve this context when used as an event listener. Locates the cart drawer placeholder and initialises the timer.

moduleRef

protected

ModuleRefImpl

Methods

Method

Modifiers

Description

destroyCartDrawerTimer()

protected

Destroy the active cart drawer countdown timer controller.

Calls destroy() on the stored controller and nulls the reference.

getCartDrawerTimerContainer()

protected

Returns the cart drawer placeholder element for the countdown timer.

Override to change the selector used to locate the timer container inside the cart drawer.

getCartDrawerTimerScope()

protected

Returns the placement scope used when fetching the timer campaign for the cart drawer.

initCartDrawerTimer(container)

protected

Initialise a countdown timer controller for the cart drawer.

Destroys any existing cart drawer controller before creating a new one via DI. The resolved controller is stored in .

onInitBlock(block)

protected

Initialises a CountdownTimerController for the given TAE block.

Resolves a new controller instance via DI and connects it to the block's root element. Only processes blocks whose document is an HTMLElement.

setupBlockListener()

protected

Registers a TAE block listener that triggers for every countdownTimer block.

Override to listen for additional block types or add pre-filtering logic.

setupCartDrawerListener()

protected

Listens for cart drawer open/close events to manage the countdown timer lifecycle inside the cart drawer.

On open: finds the [data-countdown-timer-cart-drawer] placeholder, resolves a new controller, and connects it with cart_drawer scope. On close: destroys the active controller and clears the reference.