🕰️ Clockworker
A lightweight library to spawn workers that can loop tasks, and subscribe to events.
Installation
npm i clockworker
Usage
const { Clockworker, EventsBroker } = require('clockworker');
const myEventEmitter = new Clockworker();
myEventEmitter.loop(6000, () => EventsBroker.emit('myEvent', 'Eat'));
const myWorker = new Clockworker();
myWorker.listen('myEvent', (data) => console.log(data));
const build = () => console.log('Build');
const coffee = () => console.log('Drink Coffe');
myWorker.loop(2000, () => build());
myWorker.loop(4000, () => coffee());
License
MIT