retejs / rete

JavaScript framework for visual programming
https://retejs.org
MIT License
10.17k stars 653 forks source link

remove connection does not render #350

Closed Githamza closed 5 years ago

Githamza commented 5 years ago

I'm trying to delete connection programmatically .

Here my code

      editor.nodes[0].outputs.forEach(elm => {
        elm.connections.map(connection => elm.removeConnection(connection))
      })
      console.log(node)
    })

in my node output variable object connection is get removed. but in UI connection is still there.

Should I trigger a function in engine or editor to make the editor applying delete to UI ?

Ni55aN commented 5 years ago

You should to remove a connections using NodeEditor as it works with the view layer (Node instance, Output/Input dont have access to view layer)

node.outputs.forEach(output => {
    output.connections.map(connection => editor.removeConnection(connection))
})
Githamza commented 5 years ago

Nice that's working. I would like to know how to use removeConnections? ( all connections of a node )

Ni55aN commented 5 years ago

@Githamza it doesn't work combined with the view

lomtesaurabh commented 1 year ago

My question is, If the user removes any connection in the code how to know which connection is removed? so I can update connections.

Ni55aN commented 1 year ago

@lomtesaurabh v1 or v2?

for v1 you can listen to connectionremoved event like this:

editor.on('connectionremoved', args =>{})