Module RescriptCron
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 givencronTime
(either created with the cron format (e.g.2 * * * * * *
) or as aJs
.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 nextonTick
(and eventually other callbacks added withaddCallback
).
-
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 then
nextMoment
.t that will trigger anonTick
-
val nextJsDates : ?numberOfDates:int -> CronJob.t -> Js.Date.t array
-
nextJsDates(n, cronJob)
returns then
nextJs
.Date.t that will trigger anonTick
-
external fireOnTick : CronJob.t -> unit = "fireOnTick" "BS"
-
fireOnTick(cronJob)
will fire theonTick
and all callbacks added withaddCallback
-
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.