Reactive Countdown
Countdown utility. This library is for you whenever you need a reactive countdown or timer.
Usage
// Basic
const countdown = new Countdown({
intervalInSeconds: 5,
onComplete: () => {
// Your code here gets called when the countdown has finished.
// eg. emit to an Subject
},
});
Start a countdown
Countdown exposes an observable, as soon as we have a subscriber we can start the countdown.
countdown.secondsLeft$.subscribe();
countdown.start();
Stop/Reset a countdown
Stop will reset the countdown to its configured interval in seconds.
countdown.stop();
Properties
Property | Description | |
---|---|---|
secondsLeft$ | As soon as we have a subscriber to this property we can start the countdown. | |
onComplete$ | Emits when the countdown completes | |
isRunning$ | Observe if the countdown is running | |
isStopped$ | Observe if the countdown is stopped |