Class: Client

Client

A JSON-RPC 2.0 client that sends requests and notifications over window.postMessage.

Constructor

new Client(targetWindowopt)

Construct a Client instance.

Parameters:
Name Type Attributes Description
targetWindow Window <optional>

The default server window.

Source:

Methods

(private) _dispatch(method, id, …params)

Parameters:
Name Type Attributes Description
method
id
params * <repeatable>
Source:

mount(window)

Start listening for message events (to receive results of requests).

Parameters:
Name Type Description
window Window

The browser window to which a handler will be attached.

Source:

notify(method, targetWindowopt, …params) → {Promise}

Invoke a named RPC method on the server window, ignoring the result.

Parameters:
Name Type Attributes Description
method string
targetWindow Window <optional>

The server window to use for this invocation. Not required if this was set in the constructor.

params * <repeatable>
Source:
Returns:
  • A promise that resolves as soon as the message is posted.
Type
Promise

request(method, targetWindowopt, …params) → {Promise}

Invoke a named RPC method on the server window, ignoring the result.

Parameters:
Name Type Attributes Description
method string
targetWindow Window <optional>

The server window to use for this invocation. Not required if this was set in the constructor.

params * <repeatable>
Source:
Returns:
  • A promise that either resolves to the return value of the method, or is rejected with an error object (if the method throws).
Type
Promise

unmount(window)

Stop listening for message events.

Parameters:
Name Type Description
window Window

The browser window from which the handler will be detached.

Source: