File: example.js

Recommend this page to a friend!
  Classes of JImmy Bo   JavaScript Timed Functions   example.js   Download  
File: example.js
Role: Example script
Content type: text/plain
Description: Example Usage
Class: JavaScript Timed Functions
Call sequence of functions with given time delays
Author: By
Last change: swapped before after
Date: 10 years ago
Size: 957 bytes
 

Contents

Class file image Download
// initialize var fncTimer = new timed_functions; // set some defaults fncTimer.set.delay_default(1000); // set a default delay between function blocks fncTimer.set.blocking_on(); // next timer begins count after code is executed fncTimer.set.blocking_off(); // next timer begins count before code is executed // fncTimer.set.loop_on(); // when finished start over // fncTimer.set.loop_off(); // BEGIN :: ADD FUNCTIONS (they will fire off in order) fncTimer.add.fnc(function() { console.log('plan a (2 secs)'); }); fncTimer.set.delay(2000); // set custom delay for previously added function fncTimer.add.fnc(function() { console.log('hello world (delay 3 seconds)'); }); fncTimer.set.delay(3000); fncTimer.add.fnc(function() { console.log('wait 4 seconds...'); }); fncTimer.set.delay(4000); // END :: ADD FUNCTIONS // NOW RUN fncTimer.cycle(); // begin execution