lazyReplace<P> method

void lazyReplace<P>(
  1. InstanceBuilderCallback<P> builder, {
  2. String? tag,
  3. bool? fenix,
})

Replaces an existing registered dependency of type P with a new lazy factory builder.

If the existing instance is permanent, it will be forcefully deleted first.

  • tag Optional tag to identify the instance.
  • fenix If true, the builder callback will persist in memory to recreate the instance if deleted. If not provided, defaults to true if the parent instance was permanent.

Implementation

void lazyReplace<P>(
  InstanceBuilderCallback<P> builder, {
  String? tag,
  bool? fenix,
}) {
  final info = getInstanceInfo<P>(tag: tag);
  final permanent = (info.isPermanent ?? false);
  delete<P>(tag: tag, force: permanent);
  lazyPut(builder, tag: tag, fenix: fenix ?? permanent);
}