putLazy<T> method

void putLazy<T>(
  1. T factory(), {
  2. String? tag,
  3. bool isPermanent = false,
  4. bool alwaysNew = false,
})

Register a lazy factory

Creates singleton on first access (default behavior). Set isPermanent to true to survive scope cleanup. Set alwaysNew to true to create fresh instance on each find().

Implementation

void putLazy<T>(
  T Function() factory, {
  String? tag,
  bool isPermanent = false,
  bool alwaysNew = false,
}) {
  _scope.putLazy<T>(
    factory,
    tag: tag,
    isPermanent: isPermanent,
    alwaysNew: alwaysNew,
  );

  final behavior = alwaysNew
      ? 'factory (always new)'
      : (isPermanent ? 'permanent' : 'temporary');

  ZenLogger.logDebug('Registered lazy $behavior for $T in test container');
}