WaCron class
A class to manage and run cron jobs using the cron
package.
The WaCron class schedules and manages tasks based on the given cron schedule. It includes functionalities for delayed starts, counting executions, and tracking status.
Example:
final cronJob = WaCron(
schedule: '*/5 * * * * *', // Run every 5 seconds
onCron: (count, cron) async {
print('Task executed $count times');
},
);
cronJob.start();
Constructors
Properties
- counter → int
-
The number of times the cron task has been executed.
no setter
- delayFirstMoment ↔ bool
-
Indicates whether the first execution should be delayed.
getter/setter pair
- hashCode → int
-
The hash code for this object.
no setterinherited
- onCron ↔ Future Function(int count, WaCron cron)
-
The callback function to be executed on each cron tick.
getter/setter pair
- registerTime ↔ int
-
The time the cron was registered (in microseconds since epoch).
latefinal
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- schedule ↔ String
-
Cron schedule in string format.
getter/setter pair
- status → CronStatus
-
The current status of the cron job.
no setter
Methods
-
close(
) → void - Stops the cron job and cleans up resources.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
start(
) → WaCron - Starts the cron job.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited