onDependencyInit<S> method

void Function() onDependencyInit<S>(
  1. void onInit(),
  2. S instance,
  3. LevitScope scope,
  4. String key,
  5. LevitDependency info,
)

Called when a dependency's onInit method is about to be executed.

This method allows you to wrap the initialization logic, for example, to capture reactive variables created during initialization.

  • onInit: The original onInit function.
  • instance: The dependency instance.
  • scope: The scope where the dependency is registered.
  • key: The key of the dependency.
  • info: Metadata about the dependency.

Returns a new void function that eventually calls onInit. If you don't need to wrap onInit, simply return onInit (default behavior).

Implementation

void Function() onDependencyInit<S>(
  void Function() onInit,
  S instance,
  LevitScope scope,
  String key,
  LevitDependency info,
) =>
    onInit;