diff --git a/examples/dartness_flutter_melos/.vscode/launch.json b/examples/dartness_flutter_melos/.vscode/launch.json new file mode 100644 index 0000000..a9c1b03 --- /dev/null +++ b/examples/dartness_flutter_melos/.vscode/launch.json @@ -0,0 +1,42 @@ +{ + // Use IntelliSense para saber los atributos posibles. + // Mantenga el puntero para ver las descripciones de los existentes atributos. + // Para más información, visite: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "dartness_flutter_melos", + "request": "launch", + "type": "dart" + }, + { + "name": "my_app", + "cwd": "apps\\my_app", + "request": "launch", + "program": "lib/main.dart", + "flutterMode": "debug", + "type": "dart" + }, + { + "name": "my_app (profile mode)", + "cwd": "apps\\my_app", + "request": "launch", + "type": "dart", + "flutterMode": "profile" + }, + { + "name": "my_app (release mode)", + "cwd": "apps\\my_app", + "request": "launch", + "type": "dart", + "flutterMode": "release" + }, + { + "name": "my_server", + "cwd": "servers\\my_server", + "request": "launch", + "program": "bin\\my_server.dart", + "type": "dart" + } + ] +} diff --git a/examples/dartness_simple/lib/src/app.dart b/examples/dartness_simple/lib/src/app.dart index e9d8f5d..8169bf7 100644 --- a/examples/dartness_simple/lib/src/app.dart +++ b/examples/dartness_simple/lib/src/app.dart @@ -2,6 +2,7 @@ import 'package:dartness_server/dartness.dart'; import 'package:dartness_server/modules.dart'; import 'package:dartness_server/server.dart'; import 'package:dio/dio.dart'; +import 'package:example/src/schedulers/example_scheduler.dart'; import 'controllers/city_controller.dart'; import 'controllers/todos_controller.dart'; @@ -28,6 +29,9 @@ Dio createDio() => Dio(); classType: Dio, useFactory: createDio, ), + ProviderMetadata( + classType: ExampleScheduler, + ) ], imports: [ userModule, diff --git a/examples/dartness_simple/lib/src/app.g.dart b/examples/dartness_simple/lib/src/app.g.dart index 0fc08d5..6bff905 100644 --- a/examples/dartness_simple/lib/src/app.g.dart +++ b/examples/dartness_simple/lib/src/app.g.dart @@ -24,6 +24,7 @@ extension AppExtension on App { injectRegister.register( TodosController(injectRegister.resolve())); injectRegister.register(ExampleErrorHandler()); + injectRegister.register(ExampleScheduler()); } Future init() async { @@ -41,5 +42,6 @@ extension AppExtension on App { port: 8080, ), ); + injectRegister.resolve().initSchedules(); } } diff --git a/examples/dartness_simple/lib/src/schedulers/example_scheduler.dart b/examples/dartness_simple/lib/src/schedulers/example_scheduler.dart new file mode 100644 index 0000000..17afb9c --- /dev/null +++ b/examples/dartness_simple/lib/src/schedulers/example_scheduler.dart @@ -0,0 +1,11 @@ +import 'package:dartness_server/schedule.dart'; + +part 'example_scheduler.g.dart'; + +@Scheduler() +class ExampleScheduler { + @Scheduled(cron: "* * * * *") + void example() { + print("${DateTime.now()} Hello world"); + } +} diff --git a/examples/dartness_simple/lib/src/schedulers/example_scheduler.g.dart b/examples/dartness_simple/lib/src/schedulers/example_scheduler.g.dart new file mode 100644 index 0000000..a9a4b58 --- /dev/null +++ b/examples/dartness_simple/lib/src/schedulers/example_scheduler.g.dart @@ -0,0 +1,14 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'example_scheduler.dart'; + +// ************************************************************************** +// SchedulerGenerator +// ************************************************************************** + +extension ExampleSchedulerExtension on ExampleScheduler { + void initSchedules() { + final scheduler0 = SchedulerManager("* * * * *"); + scheduler0.start(example); + } +} diff --git a/examples/dartness_simple/pubspec.yaml b/examples/dartness_simple/pubspec.yaml index 76e8363..de6bfde 100644 --- a/examples/dartness_simple/pubspec.yaml +++ b/examples/dartness_simple/pubspec.yaml @@ -8,11 +8,13 @@ environment: sdk: ">=3.0.0 <4.0.0" dependencies: - dartness_server: ^0.6.0 + dartness_server: + path: ../../packages/dartness_server dio: ^5.3.3 dev_dependencies: build_runner: ^2.4.6 - dartness_generator: ^0.6.0 - lints: ^3.0.0 + dartness_generator: + path: ../../packages/dartness_generator + lints: ^4.0.0 test: ^1.24.9