on<E> method
Implementation
CancelListenFunc on<E>(
FutureOr<void> Function(E) then, {
bool Function(E)? filter,
}) =>
listen((event) async {
// event must be E
if (event is! E) return;
// filter must be true (if filter is used)
if (filter != null && !filter(event)) return;
// cast to E
await then(event);
});