1.0.1 • Published 4 years ago

instapublish v1.0.1

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

Minimalistic JS callback scheduler 🛵

Pure JS, no dependencies.

Installation

yarn add minicall

Quick start

import minicall from 'minicall'

const task = new minicall({
    timeSlot: [12 * 3600, 20 * 3600], //trigger the onReachedCallback every day, at 12 noon and 20pm 
    onReached: async () => await someSendingFunction('Hey this message has been sent from a scheduled task!'),
    onRunned: () => console.log('onReached has been called 🎉'),
})


task.start()

/* task.stop() */

ScheduledTask

  • Options:

    NameTypeDescriptionDefaultRequired
    timeSlotnumber[] or numberIf an array, it has to be an Array of seconds of a day where the onReached callback is going to be called at. If it's a number the callback is going to be called at every timeSlot value10,000 (10 seconds)NO
    onReached(daySecond: number) => anyCallback called when the seconds of the day reach reach one of the targets set in timeSlotundefinedYES
    onRunned() => anyCallback called when onReached has been called() => nullNO