Custom node vs subflow

I currently have a function node to dynamically generate a filename which gets passed to the file out node as msg.filename. I made each version - a subflow of the function node + file out node, and a custom node that is basically just the function node. In this case it seems to make the most sense to do a subflow, since then I can wrap both nodes up into one.

But I have another function node used multiple places that reads from a file (on its own, not with a file-in node) and adds some extra stuff to the msg. For this simpler case, where would you draw the line between making a single node subflow vs a custom node for something like this? Are there performance reasons to use one over the other if in the end it's basically just a function node wrapped up as either a subflow or custom node?

May not be directly related to your use case, but I have a couple of "single node" sub-flows (email node, pushover node) to avoid having to enter credentials multiple times. These nodes do not have a "config" node and each instance requires the same credentials, so it just makes it simpler to have them in a sub-flow and use it wherever needed.

Thanks for the input. So I guess it kind of depends on whatever works best for my use case then. The goal is really to just eliminate duplicate function node code, since this is/will be used in about 10-20 places in various flows.

I guess the trade-off is one is easy to maintain (sub-flow - changes in one place only) and the other is easier to customize (repeated code - easier to tweak for a particular use case).

If you have a input only flow (like rakgupta's pushover, which I also have) I use a Link-In/Link-Out type flow where I have my pushover node connected to a Link-In and function nodes for message formatting. I can then send any flow to it.

Stuff like that I have in its own little group and on a tab page for other like-minded flows.

Going the other way, on that same tab page, I have a group for all my timers that Link-Out to all my other flows:

image

3 Likes

I guess the trade-off is one is easy to maintain (sub-flow - changes in one place only) and the other is easier to customize (repeated code - easier to tweak for a particular use case).

Yeah that's something I've been trying to keep in mind, like using the sub-flow environment variables to allow for some customization.

I'll do some more thinking/planning and see where we end up.

Thanks again for all your help!

Hmm that's interesting, I haven't used (or even looked into) link nodes at all. That could probably come in handy for trimming down our huge amount of global variables at least.

1 Like

I use them a lot, it's very helpful for passing data between tabs or groups of nodes in a clean way. I am very OCD when it comes to making sure the flow is easily readable and not having random lines all over the screen :slight_smile:

3 Likes

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.