jerosoler / Drawflow

Simple flow library 🖥️🖱️
https://jerosoler.github.io/Drawflow/
MIT License
4.78k stars 741 forks source link

on method question #441

Closed caesaneer closed 2 years ago

caesaneer commented 2 years ago

Hello,

As part of my evaluation of Drawflow I noticed the on method, which registers events. dispatch uses the events object to call events. Where are events actually registered? What I mean is, on does not appear to be called anywhere?

Thanks!

jerosoler commented 2 years ago

It is to listen for events in your code.

See in the documentation: https://github.com/jerosoler/Drawflow#events

For example, when you delete a node, save to the database...

caesaneer commented 2 years ago

Ah, I understand now. on is not used by Drawflow directly and is provided as an API method that allows users to add listeners. All of the dispatch calls are "in-case" the user has added listeners.

Thanks for the expeditious response!

jerosoler commented 2 years ago

So you can extend the functionalities without modifying the library.

Example simple:

Example complex: