addListener method

  1. @VoltronMethod(kModuleAddListener)
void addListener(
  1. String name,
  2. JSPromise promise
)

Implementation

@VoltronMethod(kModuleAddListener)
void addListener(String name, JSPromise promise) {
  var count = 0;
  if (_eventMap.containsKey(name)) {
    count = _eventMap[name]!;
  }
  count++;

  if (count == 1) {
    handleAddListener(name);
  }
  _eventMap.remove(name);
  _eventMap[name] = count;
}