build method
Implementation
@override
EntityChangeBinding build({required String type}) {
final graph = ref.watch(entityGraphProvider);
final registry = ref.watch(entityTransportRegistryProvider);
final transport = registry.get<T>(type);
final subscription = transport.subscribe((event) {
switch (event.op) {
case ChangeOp.insert:
case ChangeOp.update:
final row = event.row;
if (row != null) {
graph.upsertEntity(type, event.id, transport.toGraph(row));
graph.setEntityFetched(type, event.id);
}
graph.invalidateListsForType(type);
case ChangeOp.delete:
graph.removeEntity(type, event.id);
}
});
if (subscription != null) ref.onDispose(subscription.cancel);
return EntityChangeBinding(isActive: subscription != null);
}