watchRelated<P extends DatumEntityInterface, R extends DatumEntityInterface> method
Stream<List<R> > ?
watchRelated<P extends DatumEntityInterface, R extends DatumEntityInterface>(
- P parent,
- String relationName
Reactively watches related entities with proper type checking
Implementation
Stream<List<R>>? watchRelated<P extends DatumEntityInterface, R extends DatumEntityInterface>(
P parent,
String relationName,
) {
// Type-safe check using sealed class pattern matching
switch (parent) {
case RelationalDatumEntity():
return Datum.managerByType(parent.runtimeType).watchRelated<R>(parent, relationName);
case _:
throw ArgumentError(
'Entity of type ${parent.runtimeType} is not relational and cannot have relations. '
'To use relations, extend RelationalDatumEntity instead of DatumEntity or use RelationalDatumEntityMixin to use `with` block.',
);
}
}