@tempest/core
Version:
The core of the Tempest Stream Library
42 lines • 1.05 kB
JavaScript
import { fatalError } from '../util/fatalError';
export class PropagateTask {
constructor(run, value, sink) {
this._run = run;
this.value = value;
this.sink = sink;
this.active = true;
}
static event(value, sink) {
return new PropagateTask(event, value, sink);
}
static error(err, sink) {
return new PropagateTask(error, err, sink);
}
static end(value, sink) {
return new PropagateTask(end, value, sink);
}
run(time) {
if (!this.active)
return;
this._run(time, this.value, this.sink);
}
error(time, err) {
if (!this.active)
fatalError(err);
this.active = false;
this.sink.error(time, err);
}
dispose() {
this.active = false;
}
}
function event(time, value, sink) {
sink.event(time, value);
}
function error(time, err, sink) {
sink.error(time, err);
}
function end(time, value, sink) {
sink.end(time, value);
}
//# sourceMappingURL=PropagateTask.js.map