Giter Club home page Giter Club logo

node-red-contrib-branch's Introduction

node-red-contrib-branch

=========================

A simple Node-RED (http://nodered.org) node to branch messages that could later be reunited by a join node.

Features

  • Leaves original payload unchanged
  • Allows for multiple parallel branches that can later be reassembed based on their _msgid.
  • Using a join node, all threads will be need to be completed before the join message forwards on the next message. The resulting payload will be an array containing all payloads from the various threads.

Install

Run the following command in the root directory of your Node-RED install (typically ~/.node-red)

npm install node-red-contrib-branch

Example

[{"id":"2e05c962.c7ab26","type":"branch","z":"ef08c8c2.ff8aa8","name":"","outputs":"3","x":260,"y":190,"wires":[["20e03ba7.61fd44"],["40dd3dd0.46b634"],["3af7730d.1bbb7c"]]},{"id":"f1068953.6ba3d8","type":"inject","z":"ef08c8c2.ff8aa8","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":120,"y":190,"wires":[["2e05c962.c7ab26"]]},{"id":"20e03ba7.61fd44","type":"function","z":"ef08c8c2.ff8aa8","name":"A","func":"msg.payload = \"A\";\nreturn msg;","outputs":1,"noerr":0,"x":390,"y":160,"wires":[["447ae828.82cd08"]]},{"id":"bbed84b0.1f5988","type":"debug","z":"ef08c8c2.ff8aa8","name":"","active":true,"console":"false","complete":"false","x":810,"y":200,"wires":[]},{"id":"40dd3dd0.46b634","type":"function","z":"ef08c8c2.ff8aa8","name":"B","func":"msg.payload = \"B\";\nreturn msg;","outputs":1,"noerr":0,"x":390,"y":210,"wires":[["9a3ba6c2.e3a468"]]},{"id":"9a3ba6c2.e3a468","type":"delay","z":"ef08c8c2.ff8aa8","name":"","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":520,"y":210,"wires":[["447ae828.82cd08"]]},{"id":"447ae828.82cd08","type":"join","z":"ef08c8c2.ff8aa8","name":"","mode":"auto","build":"string","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"","x":660,"y":200,"wires":[["bbed84b0.1f5988"]]},{"id":"3af7730d.1bbb7c","type":"function","z":"ef08c8c2.ff8aa8","name":"C","func":"msg.payload = \"C\";\nreturn msg;","outputs":1,"noerr":0,"x":390,"y":260,"wires":[["243d5cd5.8293d4"]]},{"id":"243d5cd5.8293d4","type":"delay","z":"ef08c8c2.ff8aa8","name":"","pauseType":"delay","timeout":"10","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":520,"y":260,"wires":[["447ae828.82cd08"]]}]

In this example, the final message of [ "A", "B", "C" ] will be output to the debug tab only when all timers have finshed, ie after 10 seconds.

Author

Andy Feltham, https://github.com/FilamentAI

node-red-contrib-branch's People

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.