* 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:
(descriptor, handler)
| 79 | * A handle for this subscription — call `unsubscribe()` to stop receiving the event. |
| 80 | */ |
| 81 | async addCallback(descriptor, handler) { |
| 82 | const dispatch = descriptor.type === undefined ? handler : (params) => handler(descriptor.type.fromWire(params)) |
| 83 | return this.#bidi.addCallback(descriptor.method, dispatch) |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | module.exports = { Domain, event, DOMAIN_TOKEN } |