retejs / code-plugin

7 stars 7 forks source link

Why inputs undefined or air? #4

Closed saalaus closed 5 years ago

saalaus commented 5 years ago

Why do inputs or undefined or air? As fill inputs?

Ni55aN commented 5 years ago

Please specify your question in more detail

saalaus commented 5 years ago

Worker have a inputs and outputs, as use outputs and outputs in code?

Ni55aN commented 5 years ago

Readme contains an example https://github.com/retejs/code-plugin#code

saalaus commented 5 years ago

I have inputs in empty

code(node, inputs, add) {
        add('num', node.data.time)
        console.log(inputs)
    }

>>inputs:[undefined]
Ni55aN commented 5 years ago

NumComponent does not have inputs

saalaus commented 5 years ago

I use my component, my component have inputs

class Text extends Rete.Component {
    constructor() {
        super('Text');
    }

    builder(node) {
        var prev = node.addInput(new Rete.Input('prev', "", anyType, false))
        var next = node.addOutput(new Rete.Output('next', "", anyType, false))
    }

    code(node, inputs, add) {
       add('name', "test")
        console.log(inputs)
    }
}
Ni55aN commented 5 years ago

It looks like nothing is passed to this socket. Which node is connected before?

saalaus commented 5 years ago

If node connecting before -> array [undefined], else -> array is empty (I connected 2 identical nodes)

1 node: input array empty 2 node: input array empty default

1 node: input array empty 2 node: input array [undefined] default

Ni55aN commented 5 years ago

Does the left node has add('next', "some value") in worker?