Add some comments to Flow and Subflow classes

This commit is contained in:
Nick O'Leary
2019-01-16 23:33:04 +00:00
parent 6286b34d00
commit dd72046922
2 changed files with 139 additions and 28 deletions

View File

@@ -22,8 +22,20 @@ const flowUtil = require("./util");
var Log;
/**
* This class represents a subflow - which is handled as a special type of Flow
*/
class Subflow extends Flow {
/**
* Create a Subflow object.
* This takes a subflow definition and instance node, creates a clone of the
* definition with unique ids applied and passes to the super class.
* @param {[type]} parent [description]
* @param {[type]} globalFlow [description]
* @param {[type]} subflowDef [description]
* @param {[type]} subflowInstance [description]
*/
constructor(parent,globalFlow,subflowDef,subflowInstance) {
// console.log(subflowDef);
// console.log("CREATE SUBFLOW",subflowDef.id,subflowInstance.id);
@@ -80,6 +92,14 @@ class Subflow extends Flow {
this.node_map = node_map;
}
/**
* Start the subflow.
* This creates a subflow instance node to handle the inbound messages. It also
* rewires an subflow internal node that is connected to an output so it is connected
* to the parent flow nodes the subflow instance is wired to.
* @param {[type]} diff [description]
* @return {[type]} [description]
*/
start(diff) {
var self = this;
// Create a subflow node to accept inbound messages and route appropriately
@@ -169,17 +189,19 @@ class Subflow extends Flow {
}
}
}
super.start(diff);
}
stop(stopList,removedList) {
return super.stop(stopList,removedList);
}
}
/**
* Clone a node definition for use within a subflow instance.
* Give the node a new id and set its _alias property to record
* its association with the original node definition.
* @param {[type]} subflowInstanceId [description]
* @param {[type]} def [description]
* @return {[type]} [description]
*/
function createNodeInSubflow(subflowInstanceId, def) {
let node = clone(def);
let nid = redUtil.generateId();