addObjectEvent method

void addObjectEvent(
  1. Map<int, Map<String, EBusItem>> map,
  2. dynamic registerObject, {
  3. String? action,
  4. Function? method,
})

Implementation

void addObjectEvent(Map<int, Map<String, EBusItem>> map, dynamic registerObject, {String? action, Function? method}) {
  if (registerObject == null || action.isEmptyString || method == null) {
    return;
  }
  var registerHashcode = registerObject.hashCode;
  var busList = map[registerHashcode];
  if (busList == null) {
    busList = {};
    busList[action ?? ""] = EBusItem(action ?? "", method);
    map[registerHashcode] = busList;
  } else {
    //如果同一对象(即内存地址相同),直接覆盖
    busList[action ?? ""] = EBusItem(action ?? "", method);
  }
}