watchRelated<R extends DatumEntityInterface> method
Reactively watches related entities for a given parent entity (the
internals behind the deprecated DatumManager.watchRelated).
Implementation
Stream<List<R>>? watchRelated<R extends DatumEntityInterface>(
T parent,
String relationName,
) {
if (parent is RelationalDatumEntity) {
final relation = parent.relations[relationName];
if (relation == null) {
throw ArgumentError(
'Relation "$relationName" is not defined on entity type ${parent.runtimeType}.',
);
}
} else {
throw ArgumentError(
'The parent entity must be a RelationalDatumEntity to watch relations.',
);
}
final relatedManager = Datum.manager<R>();
return manager.localAdapter.watchRelated(
parent,
relationName,
relatedManager.localAdapter,
);
}