getSyncOrNone<T extends Object> method

Option<T> getSyncOrNone<T extends Object>({
  1. Entity groupEntity = const DefaultEntity(),
  2. bool traverse = true,
})

Retrieves a synchronous dependency or None if not found or async. Single exhaustive pattern collapses the Option × Resolvable × Result state space — every "not found / not sync / not ok" branch falls into the wildcard, so we can't accidentally return a partial value.

Implementation

Option<T> getSyncOrNone<T extends Object>({
  Entity groupEntity = const DefaultEntity(),
  bool traverse = true,
}) {
  assert(T != Object, 'T must be specified and cannot be Object.');
  return switch (get<T>(groupEntity: groupEntity, traverse: traverse)) {
    Some(value: Sync(value: Ok(value: final v))) => Some(v),
    _ => const None(),
  };
}