Skip to content

Commit 8265060

Browse files
committed
evaluateNodeProperty callback handling
1 parent e97bda2 commit 8265060

2 files changed

Lines changed: 21 additions & 3 deletions

File tree

components/run-component.js

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,21 @@ module.exports = function (RED) {
55
const EVENT_START_FLOW = "comp-start-flow";
66
const EVENT_RETURN_FLOW = "comp-flow-return";
77

8-
function sendStartFlow(msg, node) {
8+
function evaluateNodeProperty(value, type, node, msg)
9+
{
10+
return new Promise((resolve, reject) => {
11+
RED.util.evaluateNodeProperty(value, type, node, msg, (err, res) => {
12+
if (err) {
13+
reject(err);
14+
} else {
15+
//console.log("Res: " + res);
16+
resolve(res);
17+
}
18+
});
19+
});
20+
}
21+
22+
async function sendStartFlow(msg, node) {
923
try {
1024
// create / update state for new execution
1125
if (typeof msg._comp == "undefined") {
@@ -67,8 +81,9 @@ module.exports = function (RED) {
6781
// an empty, optional parameter is evaluated only, if the source type is "string".
6882
// In that case, the parameter is set(!). It is not put into the message in all other cases.
6983
if (paramSource.source && paramSource.source.length > 0 || paramSource.sourceType == "str") {
70-
val = RED.util.evaluateNodeProperty(paramSource.source, paramSource.sourceType, node, msg);
84+
val = await evaluateNodeProperty(paramSource.source, paramSource.sourceType, node, msg);
7185
}
86+
//console.log("Val: " + val);
7287
if (val == null || val == undefined) {
7388
if (paramDef.required) {
7489
validationErrors[paramName] = RED._("components.message.missingProperty", { parameter: paramName });

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
{
22
"name": "node-red-contrib-components",
33
"description": "reusable flows with a well defined API. Write components and use them anywhere in your node-red app",
4-
"version": "0.3.4",
4+
"version": "0.3.5",
55
"license": "MIT",
66
"author": "Oliver Charlet <oliver.charlet@clarities.de>",
7+
"contributors": [
8+
"evervondel"
9+
],
710
"repository": {
811
"type": "git",
912
"url": "https://github.com/ollixx/node-red-contrib-components.git"

0 commit comments

Comments
 (0)