onEvent<T extends ConnectionEvent> method

void Function() onEvent<T extends ConnectionEvent>(
  1. void callback(
    1. T event
    )
)

Registers a listener for specific connection event types.

Returns a function that can be called to unregister the listener.

Example

ds.onEvent<TransactionBeginning>((event) {
  print('Transaction started');
});

Implementation

void Function() onEvent<T extends ConnectionEvent>(
  void Function(T event) callback,
) {
  _ensureInitialized();
  return _connection!.onEvent<T>(callback);
}