on<T extends DataObject> method
void
on<T extends DataObject>(
- void callback(
- T data
Registers a callback for when a DataObject of type T
is received.
Implementation
void on<T extends DataObject>(void Function(T data) callback) {
_subscriptions.add(
packets
.where((packet) => packet.data is T)
.map((packet) => packet.data as T)
.listen(callback),
);
}