node-red-contrib-actionflows
Advanced tools
Comparing version 1.1.0 to 1.2.0
module.exports = function(RED) { | ||
// var RED2 = require.main.require('node-red'); | ||
// console.log("line 3"); | ||
RED.nodes.registerType("actionflows", actionflows); | ||
function actionflows(config) { | ||
@@ -27,2 +30,3 @@ var node = this; | ||
af = new Object(); | ||
af["actions"] = new Object(); | ||
af["afs"] = new Object(); | ||
@@ -34,4 +38,14 @@ af["ins"] = new Object(); | ||
if (e.id == "runtime-state") { | ||
purge(node); | ||
map(node); | ||
var mapTO = false; | ||
var flows = []; | ||
RED.nodes.eachNode(function(cb){ | ||
flows.push(Object.assign({}, cb)); | ||
if (mapTO) { | ||
clearTimeout(mapTO); | ||
} | ||
mapTO = setTimeout(function(){ | ||
purge(node); | ||
map(node, flows); | ||
}, 500); | ||
}); | ||
} | ||
@@ -271,2 +285,3 @@ } | ||
af = new Object(); | ||
af["actions"] = new Object(); | ||
af["afs"] = new Object(); | ||
@@ -278,4 +293,14 @@ af["ins"] = new Object(); | ||
if (e.id == "runtime-state") { | ||
purge(node); | ||
map(node); | ||
var mapTO = false; | ||
var flows = []; | ||
RED.nodes.eachNode(function(cb){ | ||
flows.push(Object.assign({}, cb)); | ||
if (mapTO) { | ||
clearTimeout(mapTO); | ||
} | ||
mapTO = setTimeout(function(){ | ||
purge(node); | ||
map(node, flows); | ||
}, 500); | ||
}); | ||
} | ||
@@ -322,7 +347,5 @@ } | ||
// Map actionflows with `action in` assocations on scope settings | ||
function map(node) { | ||
function map(node, flows) { | ||
// Separate our actions from our ins | ||
var af = node.context().global.get("actionflows"); | ||
var RED2 = require.main.require('node-red'); | ||
var flows = RED2.nodes.getFlows().flows; | ||
var afs_object = af["afs"]; | ||
@@ -571,3 +594,3 @@ var ins_object = af["ins"]; | ||
var done; | ||
var event = "af:" + RED2.util.generateId(); | ||
var event = "af:" + RED.util.generateId(); | ||
var handler = function(msg) { | ||
@@ -602,2 +625,3 @@ if (ains.length > 0) { | ||
msg.payload = Object.assign({}, getParent(ain_node)); | ||
msg.settings = Object.assign({}, RED.settings); | ||
} | ||
@@ -604,0 +628,0 @@ RED.events.emit("af:" + ain_node.id, msg); |
{ | ||
"name": "node-red-contrib-actionflows", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"description": "Create extendable, loopable, and reusable design patterns for flows.", | ||
@@ -5,0 +5,0 @@ "author": "Stephen J. Carnam <steveorevo@gmail.com>", |
@@ -436,3 +436,5 @@ # node-red-contrib-actionflows | ||
This feature can be used to obtain the subflow instance name should you require | ||
a reference to it within your subflow object instance. | ||
a reference to it within your subflow object instance. In addition, the Node-RED | ||
runtime instance's settings are exposed in `msg.settings` allowing your flows to | ||
know the uiPort, settingsFile folder, httpRoot, etc. | ||
@@ -439,0 +441,0 @@ [Download the #deployed event example flow here.](/actionflows/demo/deployed.json) |
1428878
1567
449