Created
August 11, 2014 01:55
-
-
Save hovissimo/7d347a8f935bfc2fca49 to your computer and use it in GitHub Desktop.
Magic Gate function for Node-RED, it let's you repeat messages arbitrarily
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* This function node will store the last message it | |
received as long as msg.payload != "abracadabra". | |
If this function receives a msg where the payload | |
exactly equals "abracadabra" then the stored | |
message will be forwarded. | |
This function is designed for storing and replaying | |
messages to help in testing flows. You can use it | |
by wiring up between two nodes where you want to | |
control or repeat messages, and also adding an | |
INJECT input that sends a the magic word in the | |
payload. | |
---Hovis | |
*/ | |
context.storedMessage = context.storedMessage || {}; | |
if (msg.payload != "abracadabra") { | |
context.storedMessage = msg; | |
} else { | |
return context.storedMessage; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment