async-call-rpc

A lightweight JSON RPC client & server

Home > async-call-rpc > CallbackBasedChannel > setup

CallbackBasedChannel.setup() method

Setup the CallbackBasedChannel.

Signature:

setup(jsonRPCHandlerCallback: (jsonRPCPayload: unknown, hint?: undefined | 'request' | 'response') => Promise<unknown | undefined>, isValidJSONRPCPayload: (data: unknown, hint?: undefined | 'request' | 'response') => boolean | Promise<boolean>): (() => void) | void;

Parameters

Parameter Type Description
jsonRPCHandlerCallback (jsonRPCPayload: unknown, hint?: undefined | ‘request’ | ‘response’) => Promise<unknown | undefined> A function that will execute the JSON RPC request then give the result back. If the result is undefined, it means no response is created.
isValidJSONRPCPayload (data: unknown, hint?: undefined | ‘request’ | ‘response’) => boolean | Promise<boolean>  

Returns:

(() => void) | void

a function that unregister the setup.