registerChildScope static method

void registerChildScope(
  1. ZenScope childScope
)

Internal method to register child scopes created via createChild()

Implementation

static void registerChildScope(ZenScope childScope) {
  final name = childScope.name;

  // Skip registration if name is null
  if (name == null) {
    ZenLogger.logWarning('Cannot register child scope without a name');
    return;
  }

  // Register as auto-dispose scope since it's created on-demand
  _autoDisposeScopes[name] = childScope;

  // Set up parent tracking if parent exists
  if (childScope.parent != null) {
    final parentName = childScope.parent!.name;
    if (parentName != null) {
      _parentScopes[name] = parentName;
      _activeAutoDisposeChildren
          .putIfAbsent(parentName, () => <String>{})
          .add(name);
    }
  }

  ZenLogger.logDebug('📝 Registered child scope: $name');
}