worker interface.Function.getWorkerInterface - MONOGRID/gainmap-js GitHub Wiki
@monogrid/gainmap-js / worker-interface / getWorkerInterface
Function: getWorkerInterface()
getWorkerInterface(
worker
):WorkerInterfaceImplementation
Defined in: src/worker-interface.ts:33
Returns an interface where methods of the worker can be called by the host site
Parameters
worker
Returns
Example
// this assumes a vite-like bundler understands the `?worker` import
import GainMapWorker from '@monogrid/gainmap-js/worker?worker'
import { getPromiseWorker, getWorkerInterface } from '@monogrid/gainmap-js/worker-interface'
// turn our Worker into a PromiseWorker
const promiseWorker = getPromiseWorker(new GainMapWorker())
// get the interface
const workerInterface = getWorkerInterface(promiseWorker)