paper-cups

Home > paper-cups > RpcClient

RpcClient class

Remote procedure client for use over postMessage. Instantiates a message listener by default i.e. it *will* listen for incoming messages once initialized. Any event listeners are automatically finalized

Signature:

export declare class RpcClient extends EphemeralListener 

Extends: EphemeralListener

Constructors

Constructor Modifiers Description
(constructor)(parentOrigin, serialize, deserialize, logger, loggerLocale, shouldDisableLogger)   Constructs a new instance of the RpcClient class

Methods

Method Modifiers Description
listenAndWait(opcode, timeout)   Wait for the next message of a given opcode. ***This will block the main thread***.
once(opcode, handler)   Execute a subscription once. Non-blocking.
onMessage(event)   Message receiver.
sendAndWait(opcode, payload, timeout)   Execute a message exchange and *wait* for the response. ***This will block the main thread***.
sendMessage({ opcode, txId, payload, delay })    
subscribe(opcode, handler)   Subscribe to messages of type opcode.