API

Class AdvancedTimer<T>

An advanced implementation of a timer class

Type Parameters

  • T = any

Implements

Index
onEachCountObservable: Observable<ITimerData<T>> = ...

Will notify each time the timer calculates the remaining time

onStateChangedObservable: Observable<TimerState> = ...

Will trigger when the timer state has changed

onTimerAbortedObservable: Observable<ITimerData<T>> = ...

Will trigger when the timer was aborted due to the break condition

onTimerEndedObservable: Observable<ITimerData<T>> = ...

Will trigger when the timer ended successfully

  • set breakCondition(predicate: (data: ITimerData<T>) => boolean): void

    set a breaking condition for this timer. Default is to never break during count

    Parameters

    • predicate: (data: ITimerData<T>) => boolean

      the new break condition. Returns true to break, false otherwise

    Returns void

  • Will start a new iteration of this timer. Only one instance of this timer can run at a time.

    Parameters

    • timeToEnd: number = ...

      how much time to measure until timer ended

    Returns void