serinus_schedule 1.0.2
serinus_schedule: ^1.0.2 copied to clipboard
A Serinus Plugin to execute cron-like jobs, timeouts and intervals in a Dart server.

serinus_schedule provides a simple way to schedule tasks in your Serinus application. It uses the cron package for cron jobs and the Timer class for timeout and intervals. It is designed to be easy to use and integrate into your Serinus application.
Getting Started #
Installation #
To install Serinus Schedule you can use the following command:
dart pub add serinus_schedule
Usage #
To use the ScheduleModule in your Serinus application, you need to add it in the module where you want to use it. This can be done using this code:
import 'package:serinus/serinus.dart';
import 'package:serinus_schedule/serinus_schedule.dart';
class AppModule extends Module {
AppModule() : super(
imports: [
ScheduleModule()
],
controllers: [
AppController()
],
providers: [
Provider.deferred(
(ScheduleRegistry registry) => AppService(registry),
inject: [ScheduleRegistry],
type: AppService
)
]
)
}
The ScheduleModule exports the ScheduleRegistry which can now be used in the scope of the module.
class AppController extends Controller {
AppController(): super('/') {
on(Route.get('/'), (RequestContext context) {
final registry = context.use<ScheduleRegistry>();
registry.addCronJob(
'hello',
'*/5 * * * *',
() async {
print('Hello world');
}
)
})
}
}
Documentation #
You can find the documentation here.
License #
serinus_schedule and all the other Avesbox Packages are licensed under the MIT license. See the LICENSE file for more info.