Skip to content
Simple timer scheduler, that makes ensure that time will be executed only when document is not hidden
Branch: master
Clone or download
Latest commit a61318c Jul 7, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src 🥚 Initial commit Jul 7, 2019
.babelrc 🥚 Initial commit Jul 7, 2019
.eslintrc 🥚 Initial commit Jul 7, 2019
.gitignore 🥚 Initial commit Jul 7, 2019
LICENSE Create LICENSE Jul 7, 2019
package-lock.json 🥚 Initial commit Jul 7, 2019
package.json 🥚 Initial commit Jul 7, 2019
readme.md 🥚 Initial commit Jul 7, 2019

readme.md

visible-timer

Simple timer scheduler, that makes ensure that time will be executed only when document is not hidden


Installation

npm install visible-timer

Usage

  // You can use those as you usually do
  import {
    clearInterval,
    clearTimeout,
    setInterval,
    setTimeout,
  } from 'visible-timer';

  // But callback won't be executed unless document.hidden is false
  const timeout = setTimeout(() => console.log(42));
  clearTimeout(timeout);

Advanced

  // You can use those as you usually do
  import {
    timerCreator,
  } from 'visible-timer/timer-creator';

  // But callback won't be executed unless document.hidden is false
  const {
    clearInterval,
    clearTimeout,
    setInterval,
    setTimeout,
    setPausedState,
  } = timerCreator();

  // You can create custom sceduler by calling setPausedState with boolean

  setPausedState(true) // will pause all timeouts
  setPausedState(false) // will unpause all timeouts

LICENSE

MIT

You can’t perform that action at this time.