untilK method

  1. @protected
FutureOr<Object> untilK(
  1. Entity<Object> typeEntity, {
  2. Entity<Object>? groupEntity,
  3. bool traverse = true,
})
inherited

Implementation

@protected
FutureOr<Object> untilK(
  Entity typeEntity, {
  Entity? groupEntity,
  bool traverse = true,
}) {
  final groupEntity1 = groupEntity ?? focusGroup;

  // Check if the dependency is already registered.
  final test = getOrNullK(typeEntity, groupEntity: groupEntity1);
  if (test != null) {
    // Return the dependency if it is already registered.
    return test;
  }

  CompleterOr<FutureOr<Object>>? completer;
  completer = (completers?.registry
      .getDependencyOrNullK(
        Entity.type(CompleterOr<FutureOr<Object>>, [typeEntity]),
        groupEntity: groupEntity1,
      )
      ?.value as CompleterOr<FutureOr<Object>>?);
  if (completer != null) {
    return completer.futureOr.thenOr((value) => value);
  }
  completers ??= DIBase();

  // If it's not already registered, register a Completer for the type
  // inside the untilsContainer.
  completer = CompleterOr<FutureOr<Object>>();

  completers!.registry.setDependency(
    Dependency<CompleterOr<FutureOr<Object>>>(
      completer,
      metadata: DependencyMetadata(
        groupEntity: groupEntity1,
        preemptivetypeEntity:
            Entity.type(CompleterOr<Future<Object>>, [typeEntity]),
      ),
    ),
  );

  // Wait for the register function to complete the Completer, then unregister
  // the completer before returning the value.
  return completer.futureOr.thenOr((value) {
    completers!.registry.removeDependencyK(
      Entity.type(CompleterOr<FutureOr<Object>>, [typeEntity]),
      groupEntity: groupEntity1,
    );
    return getK(
      typeEntity,
      groupEntity: groupEntity,
      traverse: traverse,
    );
  });
}