registerAsync<T, R extends T> method
Register an async singleton with asynchronous initialization.
The async singleton is scoped to this container.
Type Parameters:
T: The interface or base type to registerR: The concrete implementation (must extend or implementT)
Parameters:
locator: Async factory function called once to create the singletonname: Optional name qualifier for named instances
Implementation
void registerAsync<T, R extends T>(SpotAsyncGetter<R> locator, {String? name}) {
final key = SpotKey<T>(T, name);
if (registry.containsKey(key) && logging) {
log.w('Overriding async singleton in scope: $key with $R');
}
registry[key] = SpotService<T>(
SpotType.asyncSingleton,
null,
R,
asyncLocator: locator as SpotAsyncGetter<T>,
);
if (logging) log.v('Registered async singleton in scope: $key -> $R');
}