@baklavajs/core
Advanced tools
Comparing version 2.0.2-alpha.0 to 2.0.2-alpha.1
@@ -105,13 +105,20 @@ "use strict"; | ||
onDestroy() { } | ||
addInterface(type, key, io) { | ||
initializeIo() { | ||
Object.entries(this.inputs).forEach(([key, intf]) => this.initializeIntf("input", key, intf)); | ||
Object.entries(this.outputs).forEach(([key, intf]) => this.initializeIntf("output", key, intf)); | ||
} | ||
initializeIntf(type, key, intf) { | ||
intf.isInput = type === "input"; | ||
intf.events.setValue.subscribe(this, () => this.events.update.emit({ type, name: key, intf })); | ||
} | ||
addInterface(type, key, intf) { | ||
const beforeEvent = type === "input" ? this.events.beforeAddInput : this.events.beforeAddOutput; | ||
const afterEvent = type === "input" ? this.events.addInput : this.events.addOutput; | ||
const ioObject = type === "input" ? this.inputs : this.outputs; | ||
if (beforeEvent.emit(io)) { | ||
if (beforeEvent.emit(intf)) { | ||
return false; | ||
} | ||
ioObject[key] = io; | ||
io.isInput = type === "input"; | ||
io.events.setValue.subscribe(this, () => this.events.update.emit({ type, name: key, intf: io })); | ||
afterEvent.emit(io); | ||
ioObject[key] = intf; | ||
this.initializeIntf(type, key, intf); | ||
afterEvent.emit(intf); | ||
return true; | ||
@@ -118,0 +125,0 @@ } |
@@ -102,13 +102,20 @@ import { v4 as uuidv4 } from "uuid"; | ||
onDestroy() { } | ||
addInterface(type, key, io) { | ||
initializeIo() { | ||
Object.entries(this.inputs).forEach(([key, intf]) => this.initializeIntf("input", key, intf)); | ||
Object.entries(this.outputs).forEach(([key, intf]) => this.initializeIntf("output", key, intf)); | ||
} | ||
initializeIntf(type, key, intf) { | ||
intf.isInput = type === "input"; | ||
intf.events.setValue.subscribe(this, () => this.events.update.emit({ type, name: key, intf })); | ||
} | ||
addInterface(type, key, intf) { | ||
const beforeEvent = type === "input" ? this.events.beforeAddInput : this.events.beforeAddOutput; | ||
const afterEvent = type === "input" ? this.events.addInput : this.events.addOutput; | ||
const ioObject = type === "input" ? this.inputs : this.outputs; | ||
if (beforeEvent.emit(io)) { | ||
if (beforeEvent.emit(intf)) { | ||
return false; | ||
} | ||
ioObject[key] = io; | ||
io.isInput = type === "input"; | ||
io.events.setValue.subscribe(this, () => this.events.update.emit({ type, name: key, intf: io })); | ||
afterEvent.emit(io); | ||
ioObject[key] = intf; | ||
this.initializeIntf(type, key, intf); | ||
afterEvent.emit(intf); | ||
return true; | ||
@@ -115,0 +122,0 @@ } |
@@ -82,2 +82,4 @@ import { PreventableBaklavaEvent, BaklavaEvent, SequentialHook, IBaklavaEventEmitter, IBaklavaTapable } from "@baklavajs/events"; | ||
onDestroy(): void; | ||
protected initializeIo(): void; | ||
private initializeIntf; | ||
private addInterface; | ||
@@ -84,0 +86,0 @@ private removeInterface; |
{ | ||
"name": "@baklavajs/core", | ||
"version": "2.0.2-alpha.0", | ||
"version": "2.0.2-alpha.1", | ||
"description": "Core logic of BaklavaJS, a graph editor / node editor for the web", | ||
@@ -29,3 +29,3 @@ "author": "newcat <freddy.wagner@web.de>", | ||
"dependencies": { | ||
"@baklavajs/events": "^2.0.2-alpha.0", | ||
"@baklavajs/events": "^2.0.2-alpha.1", | ||
"uuid": "^8.3.2" | ||
@@ -50,3 +50,3 @@ }, | ||
}, | ||
"gitHead": "fa0da75cf1e6ebf4d9fd82dee193a86aeefa8de5" | ||
"gitHead": "c57a6bc697510860941044433acdbe28007cef88" | ||
} |
99458
2530