addSingletonCallback method
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:
IllegalArgumentException
if name is null or emptyPodNotFoundException
if no singleton exists with the given name
Example:
singletonRegistry.addSingletonCallback('userService', (userService) {
print('UserService initialized: $userService');
});
Implementation
@override
void addSingletonCallback(String name, Class type, Consumer<Object> callback) {
// local-only mutation. registering on parent implicitly is surprising.
getPodFactory().addSingletonCallback(name, type, callback);
}