mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Add SubflowModule class for running subflow modules
This commit is contained in:
parent
0c9fd25d3e
commit
814fc8bc69
@ -504,11 +504,49 @@ function remapSubflowNodes(nodes,nodeMap) {
|
||||
}
|
||||
}
|
||||
|
||||
class SubflowModule extends Subflow {
|
||||
/**
|
||||
* Create a Subflow Module object.
|
||||
* This is a node that has been published as a subflow.
|
||||
* @param {[type]} parent [description]
|
||||
* @param {[type]} globalFlow [description]
|
||||
* @param {[type]} subflowDef [description]
|
||||
* @param {[type]} subflowInstance [description]
|
||||
*/
|
||||
constructor(type, parent,globalFlow,subflowDef,subflowInstance) {
|
||||
super(parent,globalFlow,subflowDef,subflowInstance);
|
||||
this.TYPE = `module:${type}`;
|
||||
this.subflowType = type;
|
||||
}
|
||||
|
||||
/**
|
||||
* [log description]
|
||||
* @param {[type]} msg [description]
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
log(msg) {
|
||||
if (msg.id) {
|
||||
msg.id = this.id
|
||||
}
|
||||
if (msg.type) {
|
||||
msg.type = this.subflowType
|
||||
}
|
||||
super.log(msg);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function createSubflow(parent,globalFlow,subflowDef,subflowInstance) {
|
||||
return new Subflow(parent,globalFlow,subflowDef,subflowInstance)
|
||||
}
|
||||
|
||||
|
||||
function createModuleInstance(type, parent,globalFlow,subflowDef,subflowInstance) {
|
||||
return new SubflowModule(type, parent,globalFlow,subflowDef,subflowInstance);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
init: function(runtime) {},
|
||||
create: createSubflow
|
||||
create: createSubflow,
|
||||
createModuleInstance: createModuleInstance
|
||||
}
|
||||
|
@ -120,7 +120,8 @@ function createNode(flow,config) {
|
||||
}
|
||||
})
|
||||
|
||||
var subflow = require("./Subflow").create(
|
||||
var subflow = require("./Subflow").createModuleInstance(
|
||||
nodeTypeConstructor.type,
|
||||
flow,
|
||||
flow.global,
|
||||
subflowConfig.subflows[nodeTypeConstructor.subflow.id],
|
||||
|
Loading…
Reference in New Issue
Block a user