onMessage<T> method

void Function() onMessage<T>(
  1. void handler(
    1. T
    )
)

Register a message handler. Returns a function to unsubscribe.

Implementation

void Function() onMessage<T>(void Function(T) handler) {
  _handlers.add(handler as void Function(dynamic));
  return () {
    _handlers.remove(handler);
  };
}