call method

R? call()

Implementation

R? call() {
  if (_calling.contains(_identifier)) {
    if (onDuplicatedCall != null) onDuplicatedCall!(this);
    return null;
  }

  _calling.add(_identifier);
  try {
    var ret = function();
    if (ret is Future) {
      var future = ret as Future;
      _callsFuture[_identifier] = future;
      future.then((value) {
        _finalizeCall();
        return value;
      });
      return null;
    } else {
      _finalizeCall();
      return ret;
    }
  } catch (e) {
    _finalizeCall();
    rethrow;
  }
}