on<T> method
Attach a listener to the event emitter.
Calls the callback whenever there's a new event of the specified type and data type.
This method can be used with generalized types, such as Object/dynamic and other super classes.
It can be canceled using the StreamSubscription from the .listen( ... ).
StreamEventEmitter events = StreamEventEmitter();
...
events.on<String>('message').listen((String data) => print('String: $data'));
Implementation
Stream<T> on<T>([String? type]) =>
onEvent<Event<T>>(type).map((event) => event.data);