rpcContract<TInput, TOutput> function

BloomRpcContract<TInput, TOutput> rpcContract<TInput, TOutput>({
  1. required BloomHttpMethod method,
  2. required String pathTemplate,
  3. dynamic encodeInput(
    1. TInput input
    )?,
  4. TInput decodeInput(
    1. dynamic json
    )?,
  5. dynamic encodeOutput(
    1. TOutput output
    )?,
  6. TOutput decodeOutput(
    1. dynamic json
    )?,
  7. String? summary,
  8. String? description,
  9. List customCacheKey(
    1. TInput input
    )?,
})

Convenience factory function for declaring a BloomRpcContract.

final getUser = rpcContract<void, User>(
  method: BloomHttpMethod.get,
  pathTemplate: '/users/:id',
  decodeOutput: User.fromJson,
);

Implementation

BloomRpcContract<TInput, TOutput> rpcContract<TInput, TOutput>({
  required BloomHttpMethod method,
  required String pathTemplate,
  dynamic Function(TInput input)? encodeInput,
  TInput Function(dynamic json)? decodeInput,
  dynamic Function(TOutput output)? encodeOutput,
  TOutput Function(dynamic json)? decodeOutput,
  String? summary,
  String? description,
  List<dynamic> Function(TInput input)? customCacheKey,
}) {
  return BloomRpcContract<TInput, TOutput>(
    method: method,
    pathTemplate: pathTemplate,
    encodeInput: encodeInput,
    decodeInput: decodeInput,
    encodeOutput: encodeOutput,
    decodeOutput: decodeOutput,
    summary: summary,
    description: description,
    customCacheKey: customCacheKey,
  );
}