withArgument<T, R> static method

IsolatedWork<R> withArgument<T, R>(
  1. T argument,
  2. FutureOr<R> computation(
    1. T arg
    ), {
  3. CancellationToken? token,
})

Creates an instance of ZonedWork.

Parameters:

  • argument: Argument to pass to the computation function.
  • computation: A function that represents a computation.
  • token: Cancellation token used for canceling the execution of computation.

If the token parameter is specified, it can be retrieved in the computation] body by calling Task.token.
Token-based cancellation is a very flexible cancellation method, implemented solely based on the cancellation request processing logic.

Implementation

static IsolatedWork<R> withArgument<T, R>(
  T argument,
  FutureOr<R> Function(T arg) computation, {
  CancellationToken? token,
}) {
  return IsolatedWork(() => computation(argument), token: token);
}