UNPKG

@uwdata/mosaic-core

Version:

Scalable and extensible linked data views.

52 lines 1.52 kB
import { MosaicClient } from './MosaicClient.js'; import { coordinator as defaultCoordinator } from './Coordinator.js'; /** * Make a new client with the given options, and connect the client to the * provided coordinator. * @param options The options for making the client. * @returns The resulting client. */ export function makeClient(options) { const { coordinator = defaultCoordinator(), ...clientOptions } = options; const client = new ProxyClient(clientOptions); coordinator.connect(client); return client; } /** * An internal class used to implement the makeClient API. */ class ProxyClient extends MosaicClient { _methods; _filterStable; /** * @param options The options for making the client. */ constructor({ selection = undefined, enabled = true, filterStable = true, ...methods }) { super(selection); this.enabled = enabled; this._methods = methods; this._filterStable = filterStable; } get filterStable() { return this._filterStable; } async prepare() { await this._methods.prepare?.(); } query(filter) { return this._methods.query?.(filter) ?? null; } queryResult(data) { this._methods.queryResult?.(data); return this; } queryPending() { this._methods.queryPending?.(); return this; } queryError(error) { this._methods.queryError?.(error); return this; } } //# sourceMappingURL=make-client.js.map