Way to execute a function on flow deployment?

246 views
Skip to first unread message

Cody Walker

unread,
Jul 1, 2015, 4:34:05 PM7/1/15
to node...@googlegroups.com
I'm working with a node that has a data endpoint, and a portion that needs to retrieve data from that endpoint.
Is there a way, either in the editor portion, or the actual custom node code, that I can execute a function when the flows are redeployed?

Essentially I'm looking for a flow like this:
1 - Something is modified in the editor
2 - This causes the endpoint to have new data available
3 - <function on deploy that triggers #4>
4 - Regather data from endpoint

Thanks,

Cody

Nicholas O'Leary

unread,
Jul 1, 2015, 4:46:39 PM7/1/15
to Node-RED Mailing LIst
Cody,

there is no event in the editor that can be used to trigger a custom action on deploy.

Where in the UI does your node present the data from the end point? If it is part of the node's edit dialog then you will be calling your end point as part of oneditprepare - it isn't possible to have the dialog open and deploy, so your UI wouldn't be visible at deploy time to need refreshing.

If you're adding a custom sidebar tab (as the debug node does for example), then... yes... something else is needed.

Or if you're doing something else entirely... what exactly are you doing?

Nick



--
http://nodered.org
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Cody Walker

unread,
Jul 1, 2015, 5:43:50 PM7/1/15
to node...@googlegroups.com
Hey Nick,

You were right on the money.
I'm looking to build a sidebar tab that will be able to show swagger-ui as an extension of the dynamically generated swagger plugin.
The http node that presents the swagger does not actually get updated until deploy is clicked (as the "swagger doc" config node is part of the http input node in the flow).
Is there something to tap into from the custom node js code that is running?
If that is the case, I would be able to use a websocket or something of the sort to alert the sidebar tab of a change.

Nicholas O'Leary

unread,
Jul 1, 2015, 6:11:57 PM7/1/15
to Node-RED Mailing LIst
(Context for the community - Cody is working on some enhancements to our swagger node - https://github.com/node-red/node-red-node-swagger - that lets you document your HTTP endpoints)


So if there was a event emitted within the editor when a deploy completes, your sidebar tab could listen for that event and trigger a reload of the swagger ui content at that point in time. Correct?

Some of the internal components already emit events for certain things - we've not formalised them as any sort of API, but it would make sense to have one for the deploy event.

Will figure out the right place to hang it off tomorrow.

Nick


Cody M Walker

unread,
Jul 1, 2015, 6:19:34 PM7/1/15
to node...@googlegroups.com

Precisely. I would just need a way to be alerted, either in the node or the editor, of a deploy event, so I would know when to reload the swagger.

You received this message because you are subscribed to a topic in the Google Groups "Node-RED" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/node-red/K690Ed0cebA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to node-red+u...@googlegroups.com.

Julian Knight

unread,
Jul 2, 2015, 1:43:00 AM7/2/15
to node...@googlegroups.com
Not sure if this is a dumb question but would it make sense to have not only a global event for when a Deploy completes but also a detailed event for when a node (and/or its associated wire?) updates? In the latter case, the event could contain the template name so that templates could listen only for their own updates. Otherwise wouldn't the templates have to all update themselves on every Deploy?

Cody Walker

unread,
Jul 2, 2015, 10:36:46 AM7/2/15
to node...@googlegroups.com
Hey Julian,

Couldn't that sort of behavior be achieved with the oneditsave function of a node? If you were explicitly waiting for the deploy action afterwards, I suppose you would still need to know about that event, but you would at least know what updated.
I'm wondering about how the deploy is enabled. If there is simply a single "dirty" flag that enables the deploy button, coupled with the deploy action seemingly stopping and starting all flows, it may be difficult to determine who updated.
disclaimer: Total shot in the dark here.
Reply all
Reply to author
Forward
0 new messages