1.0.0 • Published 2 years ago

clockworker v1.0.0

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

🕰️ Clockworker

code style: prettier

A lightweight library to spawn workers that can loop tasks, and subscribe to events.

Installation

npm i clockworker

Usage

const { Clockworker, EventsBroker } = require('clockworker');

// Instance a worker that sends an event every 6 seconds
const myEventEmitter = new Clockworker();
myEventEmitter.loop(6000, () => EventsBroker.emit('myEvent', 'Eat'));

// Instance worker
const myWorker = new Clockworker();

// ... which listen to events ...
myWorker.listen('myEvent', (data) => console.log(data));

// ... and loops tasks.
const build = () => console.log('Build');
const coffee = () => console.log('Drink Coffe');
myWorker.loop(2000, () => build()); //Loop every 2 seconds
myWorker.loop(4000, () => coffee()); //Loop every 4 seconds

License

MIT

1.0.0

2 years ago

0.1.1

3 years ago

0.1.0

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.1

3 years ago