DependsOn constructor

const DependsOn(
  1. List<String> value
)

A Jetleaf annotation that declares explicit dependencies between pods.

By default, Jetleaf resolves dependencies automatically based on injection points. Use @DependsOn when you need to enforce initialization order or guarantee that certain infrastructure pods are created before the annotated pod.

Key Features:

  • Ensures initialization order in complex graphs.
  • Can declare multiple dependencies.
  • Works on both classes and methods.

Example:

@Component()
@DependsOn(["emailNotifier", "databaseService"])
class ApplicationService {
  // This service will be initialized after DatabaseService and CacheService
}

Method-level Example:

class Config {
  @Pod()
  @DependsOn(["connectionPool"])
  DatabaseClient databaseClient() => DatabaseClient();
}

Implementation

const DependsOn(this.value);