chrisgoringe / Comfy-Custom-Node-How-To

An unofficial practical guide to getting started developing custom nodes for ComfyUI
GNU General Public License v3.0
143 stars 5 forks source link

How do I communicate with the javascript front end? #2

Closed chrisgoringe closed 9 months ago

Lerc commented 9 months ago

On the python side the execution function set in FUNCTION can return information for the user interface return { "ui": {"name":value}}

Handling of the data returned by the execution function is at https://github.com/comfyanonymous/ComfyUI/blob/77c124c5a17534e347bdebbc1ace807d61416147/execution.py#L78

On the JavaScript side nodes have an onExecuted event

node.onExecuted = (output)=> {
    if (output?.name {
        console.log(output.name)
    }      
  }
chrisgoringe commented 9 months ago

Thanks - added (btw, feel free to stick answers into the markdown as a PR!)