Dex TypeScript SDK 1.29.0
    Preparing search index...

    Function rpc

    Creates a typed RPC method decorator.

    Registry construction validates handler shape, unique names, and locks. The handler receives Context and optional input, then returns RPCResult or void. Omitted input and output codecs use JSON. Scalar wire kinds still need an explicit codec. A method with only a Context parameter and a void return is a procedure. Default-parameter methods report Function.length without those parameters, so pass inputCodec when a trailing input uses a default.

    @rpc()
    describe(_context: Context, order: Order): RPCResult<Order> {
    return { output: order };
    }

    @rpc({ inputCodec: stringCodec, outputCodec: booleanCodec, timeoutMs: 10_000 })
    async cancel(context: Context, reason: string): Promise<RPCResult<boolean>> {
    return { output: true };
    }

    Codecs and optional name, timeout, and lock settings.

    A stage-3 method decorator.

    RangeError when timeoutMs is negative.

    • Decorates a Flow method as an RPC handler.

      Type Parameters

      • Input = unknown

        Handler input type.

      • Output = unknown

        Handler output type.

      Parameters

      Returns <This>(
          method: (this: This, context: Context, ...args: any[]) => unknown,
          context: ClassMethodDecoratorContext<
              This,
              (this: This, context: Context, ...args: any[]) => unknown,
          >,
      ) => void

      A stage-3 method decorator validated during Registry construction.