🐛 api now waits for all connected inputs to have value

This commit is contained in:
2023-04-19 12:42:18 +02:00
parent 8bfe3a5016
commit ea90ac4c6b
2 changed files with 27 additions and 2 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "graphfx",
"version": "0.4.3",
"version": "0.4.4",
"description": "Graph image processing pipeline",
"main": "src/index.ts",
"scripts": {

View File

@@ -84,7 +84,7 @@ export default class Api extends Node<typeof inputs, typeof outputs> {
}
async _update() {
if (!this.in.url.value) {
if (!this.canUpdate()) {
return;
}
@@ -102,6 +102,31 @@ export default class Api extends Node<typeof inputs, typeof outputs> {
}
}
private canUpdate(): boolean {
if (!this.in.url.value) {
return false
}
const inputs = [
'image0',
'image1',
'image2',
'image3',
'image4',
'image5',
'image6',
'image7',
]
for(const input of inputs) {
if (this.in[input].output && !this.in[input].value) {
return false
}
}
return true;
}
private async upload(): Promise<HTMLImageElement | undefined> {
const formData = await this.createFormData();