RecurrentScheduledTrigger class
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
- PeriodicTrigger
- RecurrentScheduledTrigger
- Annotations
-
- @JsonSerializable(includeIfNull: false, explicitToJson: true)
Constructors
- RecurrentScheduledTrigger({required RecurrentType type, required TimeOfDay time, DateTime? end, int separationCount = 0, int? maxNumberOfSampling, int? dayOfWeek, int? weekOfMonth, int? dayOfMonth, Duration? duration})
- Create a trigger that triggers based on a recurrent scheduled date and time.
-
RecurrentScheduledTrigger.fromJson(Map<
String, dynamic> json) -
factory
Properties
- $type ↔ String?
-
The runtime class name (type) of this object.
Used for deserialization from JSON objects.
getter/setter pairinherited
- dayOfMonth ↔ int?
-
If monthly recurrence, specify the day of the month.
getter/setter pair
- dayOfWeek ↔ int?
-
If weekly recurrence, specify which day of week.
getter/setter pair
- end ↔ DateTime?
-
End time and date. If
null
, this trigger keeps sampling forever.getter/setter pair - firstOccurrence → DateTime
-
The date and time of the first occurrence of this trigger.
no setter
- fromJsonFunction → Function
-
The function which can convert a JSON string to an object of this type.
no setteroverride
- hashCode → int
-
The hash code for this object.
no setterinherited
- jsonType → String
-
Return the
__type
to be used for JSON serialization of this class. Default is runtimeType. Only specify this if you need another type.no setterinherited - maxNumberOfSampling ↔ int?
-
Maximum number of samplings.
getter/setter pair
- period ↔ Duration
-
The period between the recurring samplings.
getter/setter pairinherited-setteroverride-getter
- requiresPrimaryDevice ↔ bool?
-
Determines whether the trigger needs to be evaluated on a primary
device (
PrimaryDeviceConfiguration
). For example, this is the case when the trigger is time bound and needs to be evaluated by a task scheduler running on a primary device.getter/setter pairinherited - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- separationCount ↔ int
-
Separation between recurrences.
getter/setter pair
- sourceDeviceRoleName ↔ String?
-
The device role name from which the trigger originates.
getter/setter pairinherited
- time ↔ TimeOfDay
-
The time of day of this trigger.
getter/setter pair
- type ↔ RecurrentType
-
The type of recurrence - daily, weekly or monthly.
getter/setter pair
- weekOfMonth ↔ int?
-
If monthly recurrence, specify the week in the month.
getter/setter pair
Methods
-
nextMonthlyDay(
DateTime fromDate) → DateTime -
The next day in a monthly occurrence from the given
fromDate
. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toJson(
) → Map< String, dynamic> -
Return a JSON encoding of this object.
override
-
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Constants
- daysPerMonth → const int
- daysPerWeek → const int