callAsync method

Future<R?> callAsync()

Implementation

Future<R?> callAsync() async {
  if (_calling.contains(_identifier)) {
    if (onDuplicatedCall != null) onDuplicatedCall!(this);
    return Future<R?>.value(null);
  }

  _calling.add(_identifier);
  try {
    var ret = function();
    if (ret is Future) {
      _callsFuture[_identifier] = ret as Future;
      return await ret;
    } else {
      return ret;
    }
  } finally {
    _finalizeCall();
  }
}