Socket
Socket
Sign inDemoInstall

@reatom/timer

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@reatom/timer

Reatom for timer


Version published
Maintainers
1
Created
Source

Simple timer model to manage some countdown.

import { reatomTimer } from '@reatom/timer'

// all options are not required
const pomodoroAtom = reatomTimer({
  name: 'pomodoroAtom',
  interval: 1000, // tick each second
  delayMultiplier: 1000, // allow to pass seconds to startTimer
  progressPrecision: 2, // progress will be rounded to 2 digits after dot
  resetProgress: true, // progress will be reset to 0 on end of timer
})

Example: https://stackblitz.com/edit/reatom-timer-pomodoro?file=src%2FApp.tsx

export interface TimerAtom extends AtomMut<number> {
  /** (delay - remains) / delay */
  progressAtom: AtomMut<number>
  /** interval in ms */
  intervalAtom: AtomMut<number> & {
    setSeconds: Action<[seconds: number], number>
  }
  /** start timer by passed interval */
  startTimer: Action<[delay: number], Promise<void>>
  /** allow to pause timer */
  pauseAtom: AtomMut<boolean>
  /** stop timer manually */
  stopTimer: Action<[], void>
  /** track end of timer. Do not call manually! */
  endTimer: Action<[], void>
}

FAQs

Package last updated on 17 Feb 2023

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