@ngxarch/countdown
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

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

Package Sidebar

Install

npm i @ngxarch/countdown

Weekly Downloads

0

Version

1.0.2

License

MIT

Unpacked Size

17.9 kB

Total Files

10

Last publish

Collaborators

  • grazianisven