putLazy<T> method
Register a lazy singleton factory
Implementation
void putLazy<T>(T Function() factory,
{String? tag, bool isPermanent = false}) {
if (_disposed) {
throw Exception('Cannot register in a disposed scope: $name');
}
final key = _makeKey<T>(tag);
final trackingKey = _getDependencyKey(T, tag);
// Store the factory for later use
_factories[key] = factory;
// Set the use count based on permanence
_useCount[trackingKey] = isPermanent ? -1 : 0;
if (ZenConfig.enableDebugLogs) {
ZenLogger.logDebug(
'Registered lazy ${isPermanent ? 'permanent' : 'temporary'} singleton for $T${tag != null ? ' with tag $tag' : ''}');
}
}