Home > async-call-rpc > AsyncCall
AsyncCall() function
Create a RPC server & client.
Signature:
export declare function AsyncCall<OtherSideImplementedFunctions = {}>(thisSideImplementation: object | Promise<object> | undefined, options: AsyncCallOptions): _AsyncVersionOf<OtherSideImplementedFunctions>;
Parameters
Parameter | Type | Description |
---|---|---|
thisSideImplementation | object | Promise<object> | undefined | The implementation when this AsyncCall acts as a JSON RPC server. Can be a Promise. |
options | AsyncCallOptions | AsyncCallOptions |
Returns:
_AsyncVersionOf<OtherSideImplementedFunctions>
Same as the OtherSideImplementedFunctions
type parameter, but every function in that interface becomes async and non-function value is removed.
Remarks
See AsyncCallOptions
thisSideImplementation can be a Promise so you can write:
export const service = AsyncCall(typeof window === 'object' ? {} : import('./backend/service.js'), {})