Skip to content

Commit

Permalink
Removed bad docs in Schedulers
Browse files Browse the repository at this point in the history
  • Loading branch information
RicardoRB committed Jun 23, 2024
1 parent adaea96 commit e84c5fb
Showing 1 changed file with 0 additions and 55 deletions.
55 changes: 0 additions & 55 deletions docs/schedulers.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,58 +26,3 @@ class ExampleScheduler {
```

In this example, the method `example()` will be called every second. As you can see, the class is annotated with `@Scheduler` to indicate that the class contains scheduler tasks and every method that needs to be scheduled is annotated with `@Scheduled` accepting as a param a cron.

Now that we have a service class to retrieve cities, let's use it inside the `CityController`:

```dart
@Controller('cities')
class CityController {
final CityService _cityService;
CityController(this._cityService);
@Post()
void create(@Body() City city) {
_cityService.create(city);
}
@Get()
List<City> findAll() {
return _cityService.findAll();
}
}
```

The `CityService` is injected through the class constructor.

# Provider registration

Now that we have defined a provider (`CityService`), and we have a consumer of that service (`CityController`), we
need to
register the service with Dartness so that it can perform the injection. We do this by editing our module file (
app.dart) and adding the service to the `providers` attribute of the `@Application()` annotation using
the `ModuleMetadata` class in order to structure the metadata and the `ProviderMetadata` class to structure our
provider.

```dart
@Application(
module: Module(
metadata: ModuleMetadata(
controllers: [
ProviderMetadata(
classType: CityController,
),
],
providers: [
ProviderMetadata(
classType: CityService,
),
],
),
),
)
class App {}
```

Dartness will now be able to resolve the dependencies of the `CityController` class.

0 comments on commit e84c5fb

Please sign in to comment.