10.0.1 • Published 6 years ago

@statetree/ticker v10.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
6 years ago

Ticker

NPM version Build codecov.io js-standard-style

Download

npm

npm install --save @statetree/ticker

docs

What?

  • Executes Functions later in animation frame / event cycle callback
  • call later: wrapper to request animation frame callback or event cycle, perks: adding priorty order

Why?

  • Cost effective Function can be broken into smaller functions and executed later
  • Loops can be broken down to smaller loops with out holding execution resources.

How?

executeInCycle

import Ticker from '@statetree/ticker';

// function to execute later
function callMeLater() {
    return "called later";
}

// excutes right after call me later function (optional)
function callback(result) {
    // consumer of this library can decide what they want to do
}

// create the ticker object
var ticker1 = new Ticker(callMeLater);

// add to execute later in animation frame callback or Event cycle callback
ticker1.executeInCycle().onDone(callback);
or
ticker1..onDone(callback);
ticker1.executeInCycle()

executeAsSmallLoopsInCycle

import Ticker from '@statetree/ticker';

const array = [];
for(let i= 0 ; i < 100; i++){
	array[i] = i;
};

function forLoopCode (index, result = 0){
	const sum = result + array[index];
	return sum;
}
let loopTicker = new Ticker( forLoopCode);
loopTicker.executeAsSmallLoopsInCycle(10, 100)
.onProgress(function (executedIndex, result){
    //
 })
 .onDone(function (result){
    //
 })
 .onError(function (error){
     console.log(error);
  })

dispose

import Ticker from '@statetree/ticker';

ticker.dispose();
10.0.1

6 years ago

3.4.1

6 years ago

3.4.0

6 years ago

3.2.0

6 years ago

3.3.0

6 years ago

3.1.5

7 years ago

3.1.4

7 years ago

3.1.2

7 years ago

3.0.2

7 years ago

3.0.1

7 years ago

3.0.0

7 years ago

2.2.0

7 years ago

2.1.5

7 years ago

2.1.4

7 years ago