getInstanceFromCache<MInstance extends MvvmInstance> method
MInstance
getInstanceFromCache<MInstance extends MvvmInstance>(})
Implementation
MInstance getInstanceFromCache<MInstance extends MvvmInstance>(
String id, {
dynamic params,
int? index,
String scopeId = BaseScopes.global,
bool withoutConnections = false,
}) {
final scope = scopeId;
if (!container.contains(scope, id, index)) {
performCheckForCyclicDependencies(id, index);
final instance = constructAndInitializeInstance<MInstance>(
id,
params: params,
);
container.addObjectInScope(
object: instance,
type: id,
scopeId: scope,
);
finishBuildingInstance(id, index);
return instance;
}
final instance = container.getObjectInScope(
type: id,
scopeId: scope,
index: index ?? 0,
) as MInstance;
if (!instance.isInitialized) {
if (withoutConnections) {
instance.initializeWithoutConnections(params);
} else {
instance.initialize(params);
}
}
return instance;
}