apply method

Future apply(
  1. Function function, {
  2. List? positionalArguments,
  3. Map<Symbol, dynamic>? namedArguments,
  4. ApplyTransactionScope? tx,
  5. Function? compensate,
  6. List? compensatePositional,
  7. Map<Symbol, dynamic>? compensateNamed,
  8. Cell? compensateCell,
})

Asynchronously applies a function to the wrapped cell.

This method acquires a lock on the cell's properties to ensure thread safety, then delegates to the cell's synchronous Cell.apply method.

Parameters:

  • function: The function to execute.
  • positionalArguments: Arguments passed by position.
  • namedArguments: Arguments passed by name.

Returns: A Future that completes with the result of the function application.

Implementation

Future apply(
  Function function, {
  List? positionalArguments,
  Map<Symbol, dynamic>? namedArguments,
  ApplyTransactionScope? tx,
  Function? compensate,
  List? compensatePositional,
  Map<Symbol, dynamic>? compensateNamed,
  Cell? compensateCell,
}) async {
  final lock = _cell._nucleus.lock;
  return lock != null
      ? lock.synchronized(() => _cell.apply(function,
          positionalArguments: positionalArguments,
          namedArguments: namedArguments))
      : Future(() => _cell.apply(function,
          positionalArguments: positionalArguments,
          namedArguments: namedArguments));
}