jagenjo / litegraph.js

A graph node engine and editor written in Javascript similar to PD or UDK Blueprints, comes with its own editor in HTML5 Canvas2D. The engine can run client side or server side using Node. It allows to export graphs as JSONs to be included in applications independently.
MIT License
6.55k stars 700 forks source link

asynchrone node #167

Open ramamama opened 4 years ago

ramamama commented 4 years ago

Hi, Great Job, I just have a question : Do you have a node sample with asynchrone function like axios ? rama

jagenjo commented 4 years ago

you can use the Events system to trigger nodes once you end an async task but then you won't be able to take advantage of the nodes pool as all the nodes assume sync execution.

It could be possible to create a way to stop graph execution until a node trigger a signal and resume afterwards but thats a use-case I never explored and it will imply refactoring some code.

ramamama commented 4 years ago

thanks to your answer

LAGENCECREE commented 3 years ago

just an idea, i could be wrong, it seems each node's code is executed on a loop frame way, and with a nodeParentOnExecute( nodeChildOnExecute( ) ) logic.

what do you think about having a property like a "processed_at" timestamp or random hash in each node, refreshed each time the node is considered executed, propagated to the descendants, and execute each node's code ONCE and ONLY if :

this will avoid recomputing same already computed inputs + allow sync/async chaining without losing the usefull visual node chaining (without events i guess)

in all cases, good job for this lib

jagenjo commented 3 years ago

it is an interesting idea, I will consider it in a future update.

LAGENCECREE commented 3 years ago

great ! im looking on my side a workaround for :