evaluate<U> method

Future<U> evaluate<U>(
  1. FutureOr<U> function(
    1. T
    )
)

Evaluates function on the isolated object and returns the result.

Implementation

Future<U> evaluate<U>(FutureOr<U> Function(T) function) async {
  if (_isClosed) {
    throw StateError('IsolatedObject<$T> is closed');
  }

  final (toChild, _, inflight) = await _connected;

  final id = _nextId++;
  final completer = Completer<U>();
  inflight[id] = completer;

  toChild.send((id: id, function: function));
  return completer.future;
}