#invokeExtensionsAsync
or #invokeExtensions
with the name of a hook.
These invoke, on all registered extensions, the appropriately named method (if present), such as setup
in the example above.
Comfy provides a variety of hooks for custom extension code to use to modify client behavior.
apiUpdateHandlers
#invokeExtensions
in app.js
to find all available hooks.
See also the sequence in which hooks are invoked.
beforeRegisterNodeDef
, which is used by the majority of extensions, and is often the only one needed.
AddNode
menu), and is used to
modify the behaviour of the node.
nodeType
parameter essentially serves as a template
for all nodes that will be created of this type, so modifications made to nodeType.prototype
will apply
to all nodes of this type. nodeData
is an encapsulation of aspects of the node defined in the Python code,
such as its category, inputs, and outputs. app
is a reference to the main Comfy app object (which you
have already imported anyway!)
nodeType.ComfyClass
, which holds the Python class name corresponding to this node,
to see if you need to modify the node. Often this means modifying the custom nodes that you have added,
although you may sometimes need to modify the behavior of other nodes (or other custom nodes
might modify yours!), in which case care should be taken to ensure interoperability.
beforeRegisterNodeDef
is to ‘hijack’ an existing method:
?.apply
ensures that if there wasn’t one this is still safe) and then
performs additional operations. Depending on your code logic, you may need to place the apply
elsewhere in your replacement code,
or even make calling it conditional.
When hijacking a method in this way, you will want to look at the core comfy code (breakpoints are your friend) to check
and conform with the method signature.
ComfyNode()
function on nodeType
which serves as a constructor).
In this hook you can make modifications to individual instances of your node.
beforeRegisterNodeDef
as described above.LiteGraph
object). This is discussed further in Comfy Objects.
afterConfigureGraph
, not setup
app.js
file. You may find similar code helpful
in understanding the execution flow.