0.1.0 • Published 2 years ago

timen v0.1.0

Weekly downloads
13
License
ISC
Repository
github
Last release
2 years ago

npm

Time Manager

Simple time manager based on requestAnimationFrame.

Installation

yarn add timen or npm i timen

Usage

import Time from 'timen';

// Create time scope
const timers = Time.create();
const now = new Date();

const sayHello = () => console.log('hello');

// Subscribe at time
timers.at(now.setMinutes(now.getMinutes() + 1), sayHello);

// Subscribe at "after N ms" (same as setTimeout)
timers.after(1000, sayHello);

// Subscribe at "every N ms" (same as setInterval)
timers.every(1000, sayHello);

// Subscribe at "next tick"
timers.nextTick(sayHello);

// Subscribe at "every next tick"
const unsubscribeIt = timers.tick(sayHello);
// Unsubscribe certain callback
unsubscribeIt();

// Unsubscribe specifyed callback
timers.clear(sayHello);

// Clear all timers in scope
timers.clear();
0.1.0

2 years ago

0.0.9

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

4 years ago

0.0.2

2 years ago

0.0.1

2 years ago