@selenite/graph-editor
Version:
A graph editor for visual programming, based on rete and svelte.
30 lines (29 loc) • 1.02 kB
JavaScript
import { AddPinNode } from '../AddPinNode';
import { getLeavesFromOutput } from '../utils';
export class SequenceNode extends AddPinNode {
constructor({ factory }) {
super({ label: 'Sequence', factory, height: 126, numPins: 2 });
this.addInExec();
this.pythonComponent.setCodeTemplateGetter(() => {
const execs = [];
for (let i = 0; i < this.numPinsAdded; i++) {
execs.push(`{{exec_${i}}}`);
}
return execs.join('\n');
});
}
onAddPin(index) {
const newPinId = index;
this.addOutExec('exec-' + index, newPinId.toString());
this.height += 47;
this.updateElement('node', this.id);
}
async execute(input, forward) {
for (const key in this.outputs) {
const promises = this.getWaitPromises(getLeavesFromOutput(this, key));
forward(key);
await Promise.all(promises);
}
super.execute(input, forward, false);
}
}