emit method

void emit(
  1. dynamic eventName, [
  2. dynamic arg
])

Implementation

void emit(eventName, [arg]) {
  var list = _emap[eventName];
  if (list == null) return;
  int len = list.length - 1;
  //反向遍历,防止订阅者在回调中移除自身带来的下标错位
  for (var i = len; i > -1; --i) {
    list[i](arg);
  }
}