cogsworth-trigger

0.0.5 • Public • Published

cogsworth-trigger

Triggers' role in cogsworth are to stream events to the scheduler whenever a schedule fires or ticks.

  • A schedule for a single event will have a trigger that ticks once.
  • A schedules for a weekly event will stream a tick to the scheduler every week.

The concept isn't complicated, but different syntaxes overlap in their capability to express the wide range of recurrence intervals users may want to express. cron and rrules cover most of the use cases, so those specific trigger implementations are provided by default in sibling packages.

interface

properties

trigger.stream // RxJs Observable
trigger[.startDate] // Date, [default `new Date()`]
trigger[.endDate] // Date, [default, null]

methods

trigger.start // undefined, must be called if "inherited" from
trigger.stop // undefined, must be called if "inherited" from

how do i write my own trigger?

it's pretty easy!

see ./SimpleTrigger for a basic example, or cogsworth-trigger-cron & cogsworth-trigger-rrule for examples.

Package Sidebar

Install

npm i cogsworth-trigger

Weekly Downloads

1

Version

0.0.5

License

MIT

Last publish

Collaborators

  • cdaringe