onEvent<T> method

Stream<T?> onEvent<T>(
  1. String eventName, {
  2. int argCount = 1,
})

Implementation

Stream<T?> onEvent<T>(String eventName, {int argCount = 1}) {
  var listener = _events[eventName];
  if (listener == null) {
    if (argCount == 4) {
      listener = JsEventListener<T>(jsProxy, eventName,
          cvtEvent: (a, b, c) => a, argCount: argCount);
    } else if (argCount == 3) {
      listener = JsEventListener<T>(jsProxy, eventName,
          cvtEvent: (a, b) => a, argCount: argCount);
    } else if (argCount == 2) {
      listener = JsEventListener<T>(jsProxy, eventName, argCount: argCount);
    } else {
      listener = JsEventListener<T>(jsProxy, eventName);
    }
    _events[eventName] = listener;
  }
  return listener.stream as Stream<T?>;
}