FlowFuse / FlowFuse/node-red-dashboard
Use async versions of `RED.util.evaluateNodeProperty`
- Dominant language
- HTML
- Stars
- 355
- Forks
- 82
- Avg merge
- 4d 23h
- Merged PRs (30d)
- 24
Description
### Description
As of NR 3.1.0, the synchronous call to `RED.util.evaluateNodeProperty` is depreciated for JSONata and will generate a warning.
Additionally, since we hope users will use dashboard2 in a cloud env, we must ensure we use the aasync version of this function for other things like `flow.` and `global.`
It make sense to avoid the syncronus call and use the async version everywhere.
To avoid callback hell, I propose we promisify the async call...
#### Promisification
```
function evaluateNodeProperty (value, type, node, msg) {
return new Promise(function (resolve, reject) {
RED.util.evaluateNodeProperty(value, type, node, msg, function (e, r) {
if (e) {
reject(e)
} else {
resolve(r)
}
})
})
}
```
#### Usage
##### in an async function
```
try {
inputData = await evaluateNodeProperty(node.inputProp, msg.inputPropType, node, msg)
} catch (err) {
// invalid
}
```
##### in a function as a promise
```
evaluateNodeProperty(node.inputProp, msg.inputPropType, node, msg)
.then( (value) => {
inputData = value
})
.catch ( (err) => {
// invalid
})
```
### Epic/Story
_No response_
### Have you provided an initial effort estimate for this issue?
I have provided an initial effort estimate
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.