mirror of
https://codeberg.org/vlw/monkeydo.git
synced 2025-09-13 15:53:40 +02:00
Multithreaded web animations and task chaining. Cue JavaScript methods with greater performance and portability using Web Workers and JSON.
Moved ack function from giveManifest to the MonkeyManager class so other functions can use it in the future. |
||
---|---|---|
do | ||
.gitignore | ||
LICENSE | ||
Monkeydo.mjs | ||
README.md |
Threaded task chaining for JavaScript
Monkeydo uses the portable data format JSON to read tasks, making it easy to read by primates and machines alike.
{
"tasks": [
[0,"myJavaSriptMethod","someArgument","anotherArgument"]
]
}
|
|
Use Monkeydo
Monkeydo comes as an importable ECMAScript 6 module. In this guide we'll import this directly from a ./modules/ folder, but any web-accesible location will work.
- Import
Monkeydo
from your repo clone or downloadimport { default } from "./modules/Monkeydo/Monkeydo.mjs";
- Define your JS methods
const methods = { myJavaScriptMethod: (foo,bar) => { console.log(foo,bar); } }
- Define your tasks in a JSON file (or directly in JavaScript)
{ "tasks": [ [0,"myJavaSriptMethod","I see trees of","green"], [300,"myJavaSriptMethod","red","roses too"], [160,"myJavaSriptMethod","I see them","bloom"], [1200,"myJavaSriptMethod","for","me and you"] ] }
- Initialize and run
Monkeydo
with your methods and manifestconst monkey = new Monkeydo(methods,manifest); monkey.do();
The example above would be the same as running:
console.log("I see trees of","green"); // Right away
console.log("red","roses too"); // 300 milliseconds after the first
console.log("I see them","bloom"); // 160 milliseconds after that one
console.log("for","me and you"); // and lastly, 1200 after that