Module BsCron

From node-cron GitHub-page: Cron is a tool that allows you to execute something on a schedule. This is typically done using the cron syntax. We allow you to execute a function whenever your scheduled job triggers. We also allow you to execute a job external to the JavaScript process using child_process. Additionally, this library goes beyond the basic cron syntax and allows you to supply a Js.Date.t object. This will be used as the trigger for your callback. Cron syntax is still an acceptable cron time format. Although the Cron patterns supported here extend on the standard Unix format to support seconds digits, leaving it off will default to 0 and match the Unix behavior.

module CronJob : sig ... end

Module for creating new cron jobs

module CronTime : sig ... end

Module for creating cron times that can be used to alter a cron job

external sendAt : [ `CronString of string | `JsDate of Js.Date.t ] -> MomentRe.Moment.t = "sendAt" "BS"

sendAt(cronTime) check for a given cronTime (either created with the cron format (e.g. 2 * * * * * *) or as a Js.Date.t) when it will fire next.

external timeout : [ `CronString of string | `JsDate of Js.Date.t ] -> float = "timeout" "BS"

timeout(cronTime) returns the number of milliseconds in the future at which to fire the next onTick (and eventually other callbacks added with addCallback).

external start : CronJob.t -> unit = "start" "BS"

start(cronJob) runs your job

external stop : CronJob.t -> unit = "stop" "BS"

stop(cronJob) stops your job

external setTime : CronJob.t -> CronTime.t -> unit = "setTime" "BS"

setTime(cronJob, cronTime) changes the time of your job. The job will be stopped if it is running (and hence must be started again to be running).

external lastDate : CronJob.t -> Js.Date.t = "lastDate" "BS"

lastDate(cronJob) returns the last date the job was executed

val nextMomentDates : ?⁠numberOfDates:int -> CronJob.t -> MomentRe.Moment.t array

nextMomentDates(n, cronJob) returns the n next Moment.t that will trigger an onTick

val nextJsDates : ?⁠numberOfDates:int -> CronJob.t -> Js.Date.t array

nextJsDates(n, cronJob) returns the n next Js.Date.t that will trigger an onTick

external fireOnTick : CronJob.t -> unit = "fireOnTick" "BS"

fireOnTick(cronJob) will fire the onTick and all callbacks added with addCallback

external addCallback : CronJob.t -> ((unit -> unit) -> unit) -> unit = "addCallback" "BS"

addCallback(cronJob) will add a callback that is fired on every tick. It is possible to add multiple callbacks.