call<I, O> method

Future<O> call<I, O>(
  1. ServerFunctionRef<I, O> function,
  2. I data, {
  3. Future<void>? cancelled,
})

Calls a value-returning server function.

Completing cancelled stops the request with RpcCancelledException.

Implementation

Future<O> call<I, O>(
  ServerFunctionRef<I, O> function,
  I data, {
  Future<void>? cancelled,
}) async {
  final response = await _send(
    function.id,
    function.method,
    data,
    encodeInput: function.encodeInput,
    cancelled: cancelled,
  );
  return _readValue<O>(response, function.decodeOutput, cancelled);
}