get method
Returns the value associated with a key in a map -- this entity is designed to track any changes to the key from which it originated.
Make sure to call disposeAll when you're done with this.
Implementation
Record<V> get(MKey? key, [V? value]) {
final currentValue = _internalGet(key, value);
if (currentValue.isNotLoaded) {
log.info("Loading missing key $key");
currentValue.load(
repository.load(repository.keyToId(key)!).then(
(loaded) async {
log.info("Load complete for missing key $key");
final initialized = repository.initialize(loaded);
await applyChanges((_) => _.change(key, currentValue));
return initialized;
},
),
);
applyChanges((_) => _.set(key!, currentValue));
} else {
log.finer(
"Not loading key ${key!.mxid}: Resolved: ${currentValue.isResolved}, IsFuture: ${currentValue.isFuture}");
}
return currentValue;
}