Class: Interval

Interval(msecs, itemProduceropt, waitforFinishProduction, maxNumTriggers, triggerInitially, enabled)

new Interval(msecs, itemProduceropt, waitforFinishProduction, maxNumTriggers, triggerInitially, enabled)

Parameters:
Name Type Attributes Default Description
msecs Number
itemProducer producerHandler.<(T|Promise.<T>)> <optional>
null Optional. Defaults to null. A function that produces an item that shall then be signaled by the scheduler. If the item is not of importance, then you may just supply an empty function or null (will be converted to an empty function then).
waitforFinishProduction Boolean true if true, the interval will be reset only when the itemProducer finished producing its item. If this is false, the interval will be reset right away if it elapses. This makes sense if producing an item takes considerable amounts of time.
maxNumTriggers Number the maximum amount of times this interval shall trigger. Supply a negative value or Number.MAX_SAFE_INTEGER to not limit this interval to any amount of occurrences.
triggerInitially Boolean if true, will trigger this interval right away, instead of waiting for the timeout to elapse once.
enabled Boolean if true, this Interval is enabled. Otherwise, its events are ignored until it get enabled.
Author:
Source:

Extends

Members

isEnabled :Boolean

Type:
  • Boolean
Overrides:
Source:

isFinished :Boolean

Type:
  • Boolean
Source:

Methods

finalize() → {this}

Additionally to finish(), this method also disables this Interval.
Source:
Returns:
this
Type
this

finish() → {this}

This method will ultimately set the number of occurences equal to the number of how many times this Interval should have been triggered. This leads to this Interval reporting that it is finished. Attempting to finish an unbounded Interval will throw an Error.
Source:
Throws:
if this is an unbounded Interval
Type
Error
Returns:
this
Type
this

(generator) preliminaryEvents(afteropt, beforeopt) → {IterableIterator.<PreliminaryScheduleEvent.<Schedule, undefined>>}

Returns the preliminary events for this Schedule in the interval as delimitated by after and before. The preliminary events returned de- pend on the Schedule's concrete implementation and some Schedule may not return any preliminary events. Ultimately, the Scheduler will schedule events, with no guarantee that these will coincide with the Schedule's reported preliminary events. Note that if either after or before (or both) are omitted and the current Schedule does not support unbounded intervals, an Error must thrown by it.
Parameters:
Name Type Attributes Description
after Date <optional>
Optional. Defaults to undefined. An inclusive start date and time.
before Date <optional>
Optional. Defaults to undefined. An exclusive end date and time.
Overrides:
Source:
Throws:
If the schedule does not support unbounded intervals.
Type
Error
Returns:
Type
IterableIterator.<PreliminaryScheduleEvent.<Schedule, undefined>>

(async) teardown()

Override and use this function for teardown logic as required by the specific sub-class. This method is useful e.g. clearing timeouts.
Overrides:
Source: