tick-manager

Utility to add functions to queues to tick using requestAnimationFrame

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
tick-manager
1.0.35 years ago5 years agoMinified + gzip package size for tick-manager in KB

Readme

Tick Manager
Utility to add functions to queues to tick using requestAnimationFrame

Install

You can install via npm or yarn

npm

npm install --save tick-manager

yarn

yarn add tick-manager

Usage

There are 3 available queues to add tick functions too: Initial Ticks, Pre Ticks, and Ticks. The manager will run all this ticks in Initial Ticks first, followed by Pre Ticks, and then finally Ticks. This can be useful if you need to guarantee that one function runs before another that uses data from the first, but you can't guarantee what order AddTick will be called in each of those functions.

Importing

You can import the any of the three functions into your project using ES6 imports
import { AddInitialTick, AddPreTick, AddTick } from 'tick-manager';

Adding a tick to an array

You can add a function to an array as follows (Note: The tick manager will begin running this function at the next animation frame and every one thereafter).
function myAmazingTickFunction() {
    // do stuff
}

AddTick(myAmazingTickFunction);