Socket
Socket
Sign inDemoInstall

@reatom/timer

Package Overview
Dependencies
Maintainers
0
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@reatom/timer

Reatom for timers


Version published
Weekly downloads
178
increased by60.36%
Maintainers
0
Weekly downloads
 
Created
Source

Timer model to manage some countdown. Useful for classic pomodoro or any time-progress states, like notifications.

import { reatomTimer } from '@reatom/timer'

// all options are not required, here are the defaults
const pomodoroAtom = reatomTimer({
  name: 'pomodoroAtom',
  interval: 1000, // `1000`ms - tick each second. Than lower, then more precise
  delayMultiplier: 1000, // `1000`ms allow to pass seconds to startTimer. Use `1` to pass ms
  progressPrecision: 2, // progress will be rounded to 2 digits after dot
  resetProgress: true, // progress will be reset to 0 on end of timer
})

The timer itself contains the ms remaining to the end of the timer (0 before start). Here is the list of available states and methods:

  • progressAtom (Atom<number>) - from 0 to 1, (delay - remains) / delay
  • intervalAtom (AtomMut<number>) - interval of ticks in ms
  • startTimer (Action<[delay: number, passed?: number], Promise<void>>) - start timer with the delay and optional start point
  • stopTimer (Action<[], void>) - stop timer manually
  • pauseAtom (AtomMut<boolean>) - allow to pause timer
  • pause (Action<[], boolean>) - switch pause state
  • endTimer (Action<[], void>) - track end of timer. Do not call manually!

Examples

FAQs

Package last updated on 22 Jun 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc