UNPKG

@openhps/core

Version:

Open Hybrid Positioning System - Core component

76 lines 2.02 kB
import 'reflect-metadata'; import { Observable } from 'threads/observable'; import { expose } from 'threads'; import { WorkerBase } from './WorkerBase'; const worker = new WorkerBase(); expose({ /** * Worker initialization * @param {WorkerData} config Worker data containing model information * @returns {Promise<void>} Initialize promise */ init(config) { return worker.init(config); }, /** * Pull from this work * @param {PullOptions} [options] Pull options * @returns {Promise<void>} Pull promise */ pull(options) { return worker.pull(options); }, /** * Push to this worker * @param {DataFrame} frame Data frame * @param {PushOptions} [options] Push options * @returns {Promise<void>} Push promise */ push(frame, options) { return worker.push(frame, options); }, /** * Input observable for pull requests * @returns {Observable<void>} Observable input */ pullOutput() { return Observable.from(worker.pullOutput); }, /** * Output observable for push events * @returns {Observable<any>} Observable output */ pushOutput() { return Observable.from(worker.pushOutput); }, eventOutput() { return Observable.from(worker.eventOutput); }, eventInput(name, event) { worker.model.emit(name, event); }, /** * Outgoing call to a service on the main thread * @returns {Observable<WorkerServiceCall>} Observable of outgoing service calls */ serviceOutputCall() { return Observable.from(worker.serviceOutputCall); }, /** * Response to an outgoing service call from the main thread * @param {WorkerServiceResponse} input Service response */ serviceOutputResponse(input) { worker.serviceOutputResponse.next(input); }, serviceInputCall(call) { return worker.callService(call); }, findAllServices() { return worker.findAllServices(); }, invokeMethod(methodName, ...args) { return worker.invokeMethod(methodName, ...args); } }); export default worker;