addSingletonCallback method

  1. @override
void addSingletonCallback(
  1. String name,
  2. Class type,
  3. Consumer<Object> callback
)
inherited

Add a callback to be executed when the singleton associated with name is initialized.

This method allows registering callbacks that will be executed when a singleton is initialized. The callback will receive the singleton instance as its parameter.

name: The name of the singleton to register the callback for callback: The callback to execute when the singleton is initialized

Throws:

Example:

singletonRegistry.addSingletonCallback('userService', (userService) {
  print('UserService initialized: $userService');
});

Implementation

@override
void addSingletonCallback(String name, Class type, Consumer<Object> callback) {
  singletonCallbacks[name] = callback;
  _singletonTypes[name] = type;
}