retejs / rete

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

V2: How to listen to a rete-event #634

Closed Refss closed 1 year ago

Refss commented 1 year ago

Hey there,

I'm having trouble figuring out how to listen to events thrown by rete.js. In the previous version, I could use "editor.on..." to do this, but I'm struggling to do the same with Version 2. I tried searching for solutions in the documentation, but couldn't find anything helpful. So, I thought it would be a good idea to ask for help here. I am specifically looking to listen to the following events: "deleting a node" and "creating a connection". I am also wondering if I can "abort" creating a connection.

Also is there a list available of all the events thrown by rete.js, like there used to be for Version 1?

Thanks a lot for your help and your work on rete!

Best regards, Ref

Refss commented 1 year ago

Nevermind. The documentation for it is under Validation, my bad. I tried looking for the keyword "event" the whole time.

Ni55aN commented 1 year ago

https://retejs.org/docs/concepts/plugin-system If you are using TS it will be easy to checkwhat values ​​can be in the type property

editor.addPipe(context => {
   context.type // connectioncreate, connectioncreated, etc
  return context
}

Example: https://github.com/retejs/readonly-plugin/blob/next/src/index.ts

Also is there a list available of all the events thrown by rete.js, like there used to be for Version 1?

I'm planning to add events in the Migration guide

Ni55aN commented 1 year ago

btw, https://retejs.org/docs/migration/#events-listening