goodtimer icon indicating copy to clipboard operation
goodtimer copied to clipboard

`onTime` functions

Open aeeed99 opened this issue 4 years ago • 0 comments

functions fire on onTimeout and onInterval, but OnTime should be added to allow users to add arbitrary events whenever they please.

As TimerOptions


new Timer("5:00", { 
  onTime: {
    "2:00": showRunningLowOnTime,
    "0:30": showVeryRunningLowOnTime
  }
});

As a method on a timer

const timer = new Timer("5:00");
timer.onTime("2:00", showRunningLowOnTime);
timer.onTime("0:30", showVeryRunningLowOnTime);
```js

## clearing `onTime` events.

```js
timer.clearOnTime("2:00");
// returns: true if a function existed and was removed, false otherwise

Changes

This effectively makes onTimeout a function for { onTime: "0:00" }, and should be refactored as such.

aeeed99 avatar Jan 16 '21 17:01 aeeed99