mirror of https://github.com/node-red/node-red.git
update demo flow to include dynamic link call (via linkcall node and function call)
parent
c50782c334
commit
0ab6803c9a
|
|
@ -1,59 +1,28 @@
|
|||
[
|
||||
{
|
||||
"id": "62ea32aa.d73aac",
|
||||
"id": "0364d0b105293afc",
|
||||
"type": "comment",
|
||||
"z": "6312c0588348b2d4",
|
||||
"name": "Example: Link Call Node",
|
||||
"info": "Link call node can call link in node then get result from link out node.",
|
||||
"x": 230,
|
||||
"y": 180,
|
||||
"z": "2cdc739225d6a4e8",
|
||||
"name": "Example: Link Call",
|
||||
"info": "### Link call node\nThe `link call` node can call a `link in` node then get result from `link out` node.\nIt can be set to a fixed target or passed a `target` in the `msg` for dynamic calling.\n\n### Function link call\nA `link in` node can be called from a function using `node.linkcall`\n",
|
||||
"x": 170,
|
||||
"y": 60,
|
||||
"wires": []
|
||||
},
|
||||
{
|
||||
"id": "c588bc36.87fec",
|
||||
"id": "f0e17fb6266e3e46",
|
||||
"type": "comment",
|
||||
"z": "6312c0588348b2d4",
|
||||
"name": "↓ call link in node",
|
||||
"z": "2cdc739225d6a4e8",
|
||||
"name": "↓ call link (fixed target)",
|
||||
"info": "",
|
||||
"x": 440,
|
||||
"y": 220,
|
||||
"x": 420,
|
||||
"y": 120,
|
||||
"wires": []
|
||||
},
|
||||
{
|
||||
"id": "cd31efb4d2c6967e",
|
||||
"type": "link call",
|
||||
"z": "6312c0588348b2d4",
|
||||
"name": "",
|
||||
"links": [
|
||||
"dbc46892c8d14c37"
|
||||
],
|
||||
"timeout": "30",
|
||||
"x": 420,
|
||||
"y": 260,
|
||||
"wires": [
|
||||
[
|
||||
"c3db64d1d2260340"
|
||||
]
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "dbc46892c8d14c37",
|
||||
"type": "link in",
|
||||
"z": "6312c0588348b2d4",
|
||||
"name": "",
|
||||
"links": [],
|
||||
"x": 315,
|
||||
"y": 340,
|
||||
"wires": [
|
||||
[
|
||||
"e10575d73f2e5352"
|
||||
]
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "6b61792143b3b0a3",
|
||||
"id": "2869c5a483bad49f",
|
||||
"type": "inject",
|
||||
"z": "6312c0588348b2d4",
|
||||
"z": "2cdc739225d6a4e8",
|
||||
"name": "",
|
||||
"props": [
|
||||
{
|
||||
|
|
@ -71,56 +40,18 @@
|
|||
"topic": "",
|
||||
"payload": "",
|
||||
"payloadType": "date",
|
||||
"x": 240,
|
||||
"y": 260,
|
||||
"x": 200,
|
||||
"y": 160,
|
||||
"wires": [
|
||||
[
|
||||
"cd31efb4d2c6967e"
|
||||
"06a8cdd201630b4c"
|
||||
]
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "e10575d73f2e5352",
|
||||
"type": "change",
|
||||
"z": "6312c0588348b2d4",
|
||||
"name": "",
|
||||
"rules": [
|
||||
{
|
||||
"t": "set",
|
||||
"p": "payload",
|
||||
"pt": "msg",
|
||||
"to": "Hello, World!",
|
||||
"tot": "str"
|
||||
}
|
||||
],
|
||||
"action": "",
|
||||
"property": "",
|
||||
"from": "",
|
||||
"to": "",
|
||||
"reg": false,
|
||||
"x": 450,
|
||||
"y": 340,
|
||||
"wires": [
|
||||
[
|
||||
"cf8438e7137bc0f0"
|
||||
]
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "cf8438e7137bc0f0",
|
||||
"type": "link out",
|
||||
"z": "6312c0588348b2d4",
|
||||
"name": "",
|
||||
"mode": "return",
|
||||
"links": [],
|
||||
"x": 595,
|
||||
"y": 340,
|
||||
"wires": []
|
||||
},
|
||||
{
|
||||
"id": "c3db64d1d2260340",
|
||||
"id": "943afa6102c26e24",
|
||||
"type": "debug",
|
||||
"z": "6312c0588348b2d4",
|
||||
"z": "2cdc739225d6a4e8",
|
||||
"name": "",
|
||||
"active": true,
|
||||
"tosidebar": true,
|
||||
|
|
@ -129,28 +60,282 @@
|
|||
"complete": "false",
|
||||
"statusVal": "",
|
||||
"statusType": "auto",
|
||||
"x": 600,
|
||||
"y": 260,
|
||||
"x": 610,
|
||||
"y": 160,
|
||||
"wires": []
|
||||
},
|
||||
{
|
||||
"id": "6d077dfa0987febb",
|
||||
"type": "comment",
|
||||
"z": "6312c0588348b2d4",
|
||||
"name": "↑called from link call node",
|
||||
"info": "",
|
||||
"x": 410,
|
||||
"y": 380,
|
||||
"id": "06a8cdd201630b4c",
|
||||
"type": "link call",
|
||||
"z": "2cdc739225d6a4e8",
|
||||
"name": "",
|
||||
"links": [
|
||||
"e1b6b1fbd9b33c6d"
|
||||
],
|
||||
"timeout": "30",
|
||||
"x": 390,
|
||||
"y": 160,
|
||||
"wires": [
|
||||
[
|
||||
"943afa6102c26e24"
|
||||
]
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "b23d2de4047ac09b",
|
||||
"type": "link call",
|
||||
"z": "2cdc739225d6a4e8",
|
||||
"name": "",
|
||||
"links": [
|
||||
"e1b6b1fbd9b33c6d"
|
||||
],
|
||||
"linkType": "dynamic",
|
||||
"timeout": "30",
|
||||
"x": 380,
|
||||
"y": 280,
|
||||
"wires": [
|
||||
[
|
||||
"94c83d101ad168b0"
|
||||
]
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "2706a2894820982a",
|
||||
"type": "inject",
|
||||
"z": "2cdc739225d6a4e8",
|
||||
"name": "",
|
||||
"props": [
|
||||
{
|
||||
"p": "payload"
|
||||
},
|
||||
{
|
||||
"p": "target",
|
||||
"v": "subroutine-1",
|
||||
"vt": "str"
|
||||
}
|
||||
],
|
||||
"repeat": "",
|
||||
"crontab": "",
|
||||
"once": false,
|
||||
"onceDelay": 0.1,
|
||||
"topic": "",
|
||||
"payload": "",
|
||||
"payloadType": "date",
|
||||
"x": 200,
|
||||
"y": 280,
|
||||
"wires": [
|
||||
[
|
||||
"b23d2de4047ac09b"
|
||||
]
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "94c83d101ad168b0",
|
||||
"type": "debug",
|
||||
"z": "2cdc739225d6a4e8",
|
||||
"name": "",
|
||||
"active": true,
|
||||
"tosidebar": true,
|
||||
"console": false,
|
||||
"tostatus": false,
|
||||
"complete": "false",
|
||||
"statusVal": "",
|
||||
"statusType": "auto",
|
||||
"x": 610,
|
||||
"y": 280,
|
||||
"wires": []
|
||||
},
|
||||
{
|
||||
"id": "53b9a0adfd8c4217",
|
||||
"id": "57355f9fbe74f23c",
|
||||
"type": "comment",
|
||||
"z": "6312c0588348b2d4",
|
||||
"name": "↑return to link call node",
|
||||
"z": "2cdc739225d6a4e8",
|
||||
"name": "↓ set msg.target",
|
||||
"info": "",
|
||||
"x": 680,
|
||||
"y": 380,
|
||||
"x": 200,
|
||||
"y": 240,
|
||||
"wires": []
|
||||
},
|
||||
{
|
||||
"id": "558bf6ebcececd37",
|
||||
"type": "inject",
|
||||
"z": "2cdc739225d6a4e8",
|
||||
"name": "",
|
||||
"props": [
|
||||
{
|
||||
"p": "payload"
|
||||
},
|
||||
{
|
||||
"p": "target",
|
||||
"v": "subroutine-1",
|
||||
"vt": "str"
|
||||
}
|
||||
],
|
||||
"repeat": "",
|
||||
"crontab": "",
|
||||
"once": false,
|
||||
"onceDelay": 0.1,
|
||||
"topic": "",
|
||||
"payload": "",
|
||||
"payloadType": "date",
|
||||
"x": 200,
|
||||
"y": 400,
|
||||
"wires": [
|
||||
[
|
||||
"9095bcd27e7c3bd7"
|
||||
]
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "4dbf26da9c203018",
|
||||
"type": "debug",
|
||||
"z": "2cdc739225d6a4e8",
|
||||
"name": "",
|
||||
"active": true,
|
||||
"tosidebar": true,
|
||||
"console": false,
|
||||
"tostatus": false,
|
||||
"complete": "false",
|
||||
"statusVal": "",
|
||||
"statusType": "auto",
|
||||
"x": 610,
|
||||
"y": 400,
|
||||
"wires": []
|
||||
},
|
||||
{
|
||||
"id": "2b032ec174258528",
|
||||
"type": "comment",
|
||||
"z": "2cdc739225d6a4e8",
|
||||
"name": "↓ call subroutine-1 from a function",
|
||||
"info": "",
|
||||
"x": 450,
|
||||
"y": 360,
|
||||
"wires": []
|
||||
},
|
||||
{
|
||||
"id": "9095bcd27e7c3bd7",
|
||||
"type": "function",
|
||||
"z": "2cdc739225d6a4e8",
|
||||
"name": "call subroutine-1",
|
||||
"func": "\nconst m = await node.linkcall('subroutine-1', msg, { timeout: 1000 })\n\nreturn m;",
|
||||
"outputs": 1,
|
||||
"timeout": 0,
|
||||
"noerr": 0,
|
||||
"initialize": "",
|
||||
"finalize": "",
|
||||
"libs": [],
|
||||
"x": 400,
|
||||
"y": 400,
|
||||
"wires": [
|
||||
[
|
||||
"4dbf26da9c203018"
|
||||
]
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "4237c6c2ee2e5c03",
|
||||
"type": "comment",
|
||||
"z": "2cdc739225d6a4e8",
|
||||
"name": "↓ call link in (target set by msg.target)",
|
||||
"info": "",
|
||||
"x": 470,
|
||||
"y": 240,
|
||||
"wires": []
|
||||
},
|
||||
{
|
||||
"id": "502424230fe03b8e",
|
||||
"type": "group",
|
||||
"z": "2cdc739225d6a4e8",
|
||||
"name": "subroutine-1",
|
||||
"style": {
|
||||
"label": true
|
||||
},
|
||||
"nodes": [
|
||||
"e1b6b1fbd9b33c6d",
|
||||
"547ff90d37be5bfa",
|
||||
"5dc4c8eee329ed86",
|
||||
"37c42be69a257586",
|
||||
"f2a44468d6af6018"
|
||||
],
|
||||
"x": 134,
|
||||
"y": 499,
|
||||
"w": 532,
|
||||
"h": 122
|
||||
},
|
||||
{
|
||||
"id": "e1b6b1fbd9b33c6d",
|
||||
"type": "link in",
|
||||
"z": "2cdc739225d6a4e8",
|
||||
"g": "502424230fe03b8e",
|
||||
"name": "subroutine-1",
|
||||
"links": [],
|
||||
"x": 175,
|
||||
"y": 540,
|
||||
"wires": [
|
||||
[
|
||||
"547ff90d37be5bfa"
|
||||
]
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "547ff90d37be5bfa",
|
||||
"type": "change",
|
||||
"z": "2cdc739225d6a4e8",
|
||||
"g": "502424230fe03b8e",
|
||||
"name": "",
|
||||
"rules": [
|
||||
{
|
||||
"t": "set",
|
||||
"p": "payload",
|
||||
"pt": "msg",
|
||||
"to": "Hello, from subroutine-1",
|
||||
"tot": "str"
|
||||
}
|
||||
],
|
||||
"action": "",
|
||||
"property": "",
|
||||
"from": "",
|
||||
"to": "",
|
||||
"reg": false,
|
||||
"x": 400,
|
||||
"y": 540,
|
||||
"wires": [
|
||||
[
|
||||
"5dc4c8eee329ed86"
|
||||
]
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "5dc4c8eee329ed86",
|
||||
"type": "link out",
|
||||
"z": "2cdc739225d6a4e8",
|
||||
"g": "502424230fe03b8e",
|
||||
"name": "",
|
||||
"mode": "return",
|
||||
"links": [],
|
||||
"x": 625,
|
||||
"y": 540,
|
||||
"wires": []
|
||||
},
|
||||
{
|
||||
"id": "37c42be69a257586",
|
||||
"type": "comment",
|
||||
"z": "2cdc739225d6a4e8",
|
||||
"g": "502424230fe03b8e",
|
||||
"name": "↑ link node \"sunbroutine-1\"",
|
||||
"info": "",
|
||||
"x": 270,
|
||||
"y": 580,
|
||||
"wires": []
|
||||
},
|
||||
{
|
||||
"id": "f2a44468d6af6018",
|
||||
"type": "comment",
|
||||
"z": "2cdc739225d6a4e8",
|
||||
"g": "502424230fe03b8e",
|
||||
"name": "return to caller ↑ ",
|
||||
"info": "",
|
||||
"x": 560,
|
||||
"y": 580,
|
||||
"wires": []
|
||||
}
|
||||
]
|
||||
Loading…
Reference in New Issue