How to use the threads.expose function in threads

To help you get started, we’ve selected a few threads examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github satoshipay / solar / src / workers / net-worker / worker.ts View on Github external
setTimeout(() => {
  // We had some issues with what appeared to be a race condition at worker spawn time
  expose(netWorker)
}, 50)
github ArkEcosystem / core / packages / core-transaction-pool / src / worker / worker.ts View on Github external
return true;
    }
}

const poolWorker = new PoolWorker();

export type WorkerApi = Pick

const workerApi: WorkerApi = {
    configure: (options: any) => poolWorker.configure(options),
    createJob: (job: ITransactionWorkerJob) => poolWorker.createJob(job),
    getObservable: () => poolWorker.getObservable(),
    updateBlockHeight: (height: number) => poolWorker.updateBlockHeight(height),
}

expose(workerApi);