publish<T> static method
Publishes a change to local watchers and, when a transport is connected and a codec is registered, outward.
Implementation
static Future<void> publish<T>(
T model, {
DVModelChangeKind kind = DVModelChangeKind.updated,
}) async {
final change = DVModelChange<T>(kind: kind, model: model);
_controllerFor(T).add(change);
final transport = _transport;
final encode = _encoders[T];
final name = _codecNames[T];
if (transport != null && encode != null && name != null) {
await transport.send(<String, Object?>{
'type': name,
'kind': kind.name,
'tenant': change.tenant,
'model': encode(model),
});
}
}