synced-interval

A interval which syncs with the clock

Usage no npm install needed!

<script type="module">
  import syncedInterval from 'https://cdn.skypack.dev/synced-interval';
</script>

README

Build Status

Synced Interval

A interval library which syncs automatically with the browser time.

Why

In React Apps the applications might be rendered at arbitrary times. When implementing a timer or a stop watch this might lead to a jumpy behaviour of the numbers as the Demo shows. This library solves this issue by syncing the timer with the time of the browser.

Usage

npm install synced-interval --save
import { 
  setSyncedInterval, 
  clearSyncedInterval, 
} from 'synced-interval';

const timeoutId = setSyncedInterval(() => { /* do something crazy */}, 200);
clearSyncedInterval(timeoutId);