compute<Q, R> function

Future<R> compute<Q, R>(
  1. ComputeCallback<Q, R> callback,
  2. Q message
)

Spawns an isolate, runs callback on that isolate, passes it message, and (eventually) returns the value returned by callback.

The function used as callback must be one that can be sent to an isolate.

Implementation

Future<R> compute<Q, R>(ComputeCallback<Q, R> callback, Q message) {
  return Isolate.run(() => callback(message));
}