Domain

Shared base for every generated BiDi domain class. See domain.d.ts for the typed surface.

Constructor

new Domain()

Methods

(async) addCallback(descriptor, handler) → {Promise.<{id: string, unsubscribe: function(): Promise.<void>}>}

Subscribes handler to a BiDi event. All the actual subscription-lifecycle work — remote subscribe/unsubscribe, per-subscription bookkeeping — lives on the connection itself (see Index#addCallback in bidi/index.js); Domain only adds the one thing the connection can't do on its own: parsing a delivered payload through the descriptor's type before the caller's handler runs.

Parameters:
NameTypeDescription
descriptor
handlerfunction

Invoked with the event's params (parsed through descriptor.type first, if one was given) each time it fires.

Returns:

A handle for this subscription — call unsubscribe() to stop receiving the event.

Type: 
Promise.<{id: string, unsubscribe: function(): Promise.<void>}>