UNPKG

@openhps/core

Version:

Open Hybrid Positioning System - Core component

45 lines 1.6 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.RemoteSourceNode = void 0; const RemoteNode_1 = require("../RemoteNode"); const Edge_1 = require("../../graph/Edge"); const SourceNode_1 = require("../SourceNode"); /** * Remote source node */ class RemoteSourceNode extends SourceNode_1.SourceNode { constructor(options) { var _a; super(options); this.remoteNode = new ((_a = options.type) !== null && _a !== void 0 ? _a : RemoteNode_1.RemoteNode)(options, this); this.uid = `${this.uid}-source`; this.once('build', this._onRemoteBuild.bind(this)); this.on('error', this._onDownstreamError.bind(this)); this.on('completed', this._onDownstreamCompleted.bind(this)); } _onRemoteBuild(graphBuilder) { // Add a remote node before this node this.remoteNode.graph = this.graph; graphBuilder.addNode(this.remoteNode); graphBuilder.addEdge(new Edge_1.Edge(this.remoteNode, this)); return this.remoteNode.emitAsync('build', graphBuilder); } onPull() { return new Promise((resolve, reject) => { this.remoteNode .pull() .then(() => { resolve(undefined); }) .catch(reject); }); } _onDownstreamError(error) { this.remoteNode.emit('error', error); } _onDownstreamCompleted(event) { this.remoteNode.emit('completed', event); } } exports.RemoteSourceNode = RemoteSourceNode; //# sourceMappingURL=RemoteSourceNode.js.map