Options
All
  • Public
  • Public/Protected
  • All
Menu

Class TimerService

whatitdoes

tracks the current status of the time and pushes needed notifications of timer state to timer related components.

Features:

  • Sends a push notification to the user if push notifications are enabled.

Hierarchy

  • TimerService

Index

Constructors

constructor

Properties

id

id: string

The id of the related recipe.

interval

interval: NodeJS.Timer

Interval object used to update the timers remaining time.

pushNotificationsService

pushNotificationsService: PushNotificationsService

handles sending push notifications.

readable

readable: string

A human readable string showing the remaining time left.

running

running: boolean = false

True if the timer is running

showTimer

showTimer: boolean = false

True if the timer is in view. On timer end, this will be true for one second after, while running will be false.

slug

slug: string

The slug of the related recipe. Needed to provide a link back to the recipe in the {@TimerComponent}.

statusBarService

statusBarService: StatusBarService

used to trigger showing/hiding the StatusBarComponent.

timeLeft

timeLeft: number = 0

Time left in the timer countdown.

timerObj

timerObj: any

Timer data passed from a recipe about how long a specific step will take.

title

title: string = "Clean to the Core"

Title of the related recipe.

Methods

changeMinute

  • changeMinute(change: number): void

Private onEachInterval

  • onEachInterval(): void
  • Triggered on each second interval of the timer.

    • Decreases the remaining time by one second
    • Updates the readable timer string
    • If the timer reaches zero, then onTimerComplete is called

    Returns void

Private onTimerComplete

  • onTimerComplete(): void
  • Called on timer completion, and not when the user simply stops the timer.

    • Sends a push notification (if enabled)
    • Stops the timer

    Returns void

resetTimer

  • resetTimer(): void

startTimer

  • startTimer(timerObj: any, title: any, slug: any, id: any): void

stopTimer

  • stopTimer(): void

toggleTimer

  • toggleTimer(timerObj: any, title: any, slug: any, id: any): void
    • Turns the timer on/off
    • Requests permission to send push notifications on first call.

    Parameters

    • timerObj: any
    • title: any
    • slug: any
    • id: any

    Returns void

Private updateReadable

  • updateReadable(): void

Generated using TypeDoc