findAsync<S> static method

Future<S> findAsync<S>({
  1. dynamic key,
  2. String? tag,
})

Asynchronously resolves a dependency of type S or identified by key or tag.

Useful for dependencies registered via lazyPutAsync. Throws an Exception if no registration is found.

Implementation

static Future<S> findAsync<S>({dynamic key, String? tag}) async {
  if (key is LevitState) {
    final result = await key.findAsyncIn(Ls.currentScope, tag: tag);
    if (result is Future) return await result as S;
    return result as S;
  }
  return Ls.findAsync<S>(tag: tag);
}