--
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.
if (msg.payload === '1') {
// Do all magic for payload 1 here
return { payload: 'I got ONE as input' }
} else if (msg.payload === '2') {
// Do all magic for payload 2 here
return { payload: 'I got TWO as input' }
}
if (msg.topic === '1') {
// Do all magic for topic 1 here
return { payload: 'I got ONE as input' }
} else if (msg.topic === '2') {
// Do all magic for topic 2 here
return { payload: 'I got TWO as input' }
}
if (msg.whatever === 'something') {}
Looks great. I was contemplating the same thing. I was going to have it import into Function nodes, but this is better.One thing I would like to see is some form of input parameter. Maybe even just one - so you could even encode multiple values, or comma separated parameters. That way one JS file could be used multiple times with different parameters.
Hmm, I don't really understand, could you clarify?
Hi Scott,err - how can it not break copy/paste into the existing function node when the existing function node doesn't accept any other parameters ? So you hvae no where to put these extra parameters in the existing function node. Everything is passed in on the msg object - and that is the same with Emil's node (afaik).
Ah right. I thought the idea of this was to replace/substitute for the existing function node, but allow editing in an external browser...
So edit the file in whatever editor you want, but point to that for from these nodes.
Ideally you would want (at least in my world) to be able to take the contents of that file and paste it into an existing function node's edit window and that function to behave the same... I think.
Ah right. I thought the idea of this was to replace/substitute for the existing function node, but allow editing in an external browser...
So edit the file in whatever editor you want, but point to that for from these nodes.
If you add 'require' to functionGlobalContext in your settings file, then you would be able to require arbitrary js files as part of a function node and invoke then
The required module would have to export a function that takes the incoming message and returns the result. It would also be subject to the same sandbox as the current function node.
I'm not advocating this approach... Just pointing to its existence.
Nick
OK. On same page now. And no. I think that is a step too far from where we want to be. The core idea is not to edit files.
No we haven't.... Ace was merged after the release was published.
It will be in the next release.
Nick
PS - just a heads up - in the latest release v0.10.4 - we have now switched over to the ACE editor for the function, template and comment nodes... this gives much better syntax highlighting and checking as well as folding etc etc... so hopefully a much nicer in browser dev experience ;-)
--