RecurrentScheduledTrigger
A trigger that triggers based on a recurrent scheduled date and time.
Supports daily, weekly and monthly recurrences. Yearly recurrence is not supported, since data sampling is not intended to run on such long time scales.
Here are a couple of examples:
// trigger every day at 13:30
RecurrentScheduledTrigger(type: RecurrentType.daily, time: TimeOfDay(hour: 13, minute: 30));
// trigger every other day at 13:30
RecurrentScheduledTrigger(type: RecurrentType.daily, separationCount: 1, time: TimeOfDay(hour: 13, minute: 30));
// trigger every wednesday at 12:23
RecurrentScheduledTrigger(type: RecurrentType.weekly, dayOfWeek: DateTime.wednesday, time: TimeOfDay(hour: 12, minute: 23));
// trigger every 2nd monday at 12:23
RecurrentScheduledTrigger(type: RecurrentType.weekly, dayOfWeek: DateTime.monday, separationCount: 1, time: TimeOfDay(hour: 12, minute: 23));
// trigger monthly in the second week on a monday at 14:30
RecurrentScheduledTrigger(type: RecurrentType.monthly, weekOfMonth: 2, dayOfWeek: DateTime.monday, time: TimeOfDay(hour: 14, minute: 30));
// trigger quarterly on the 11th day of the first month in each quarter at 21:30
RecurrentScheduledTrigger(type: RecurrentType.monthly, dayOfMonth: 11, separationCount: 2, time: TimeOfDay(hour: 21, minute: 30));
Thanks to Shantanu Kher for inspiration in his blog post on Again and Again! Managing Recurring Events In a Data Model. We are, however, not using yearly recurrence.
- Inheritance
-
- Object
- Serializable
- TriggerConfiguration
- RecurrentScheduledTrigger
- Implemented types
- Annotations
-
- @JsonSerializable(includeIfNull: false, explicitToJson: true)
Constructors
RecurrentScheduledTrigger.fromJson
RecurrentScheduledTrigger
Creates a trigger that triggers based on a recurrent scheduled date and time.
dayOfWeek is required for weekly recurrence, and dayOfMonth or weekOfMonth for monthly recurrence. The duration parameter is not used.
Constants
daysPerMonth
The number of days used as one month when computing period.
daysPerWeek
Properties
dayOfMonth
If monthly recurrence, specify the day of the month.
Used in cases when an event is scheduled on a particular day of the month, say the 25th. Possible numbers are 1..31 counting from the start of a month.
dayOfWeek
If weekly recurrence, specify which day of week.
Uses the DateTime.weekday values, i.e. 1 is Monday and 7 is Sunday.
end
End time and date. If null, this trigger keeps triggering forever.
firstOccurrence
The date and time of the first occurrence of this trigger after now.
fromJsonFunction
The function which can convert a JSON string to an object of this type.
maxNumberOfSampling
Maximum number of samplings.
There are times when we do not know the exact end time and date for recurrent sampling. But we might know how many occurrences (samplings) are needed to complete it.
period
The time between two triggers.
A month is counted as daysPerMonth days, so monthly triggers drift over time.
separationCount
Separation between recurrences.
This value signifies the interval (in days, weeks or months) before the next event instance is allowed. For example, if an event needs to be configured for every other week, then separationCount is 1. The default value is 0.
time
The time of day of this trigger. Default is midnight.
type
The type of recurrence - daily, weekly or monthly.
weekOfMonth
If monthly recurrence, specify the week in the month.
weekOfMonth is used for samplings that are scheduled for a certain week of the month – i.e., the first, second, etc. Possible values are 1,2,3,4. The first week is the week of the first Monday of a month. For example, the first week of September 2020 is the week starting on Monday 2020-09-07.
Methods
nextMonthlyDay
The next day in a monthly occurrence from the given fromDate.
toJson
Return a JSON encoding of this object.
toString
A string representation of this object.
Some classes have a default textual representation, often paired with a static parse function (like int.parse). These classes will provide the textual representation as their string representation.
Other classes have no meaningful textual representation that a program will care about. Such classes will typically override toString to provide useful information when inspecting the object, mainly for debugging or logging.