Added a "connectFrom()" convenience method to ValueConsumer
#include <stdint.h>
#include <ArduinoJson.h>
+template <typename T> class ValueProducer;
+
/**
* A ValueConsumer is any piece of code (like a transformation) or device that
* accepts data for input. They can accept one or more input values
@@ -24,6 +26,12 @@ class ValueConsumer {
virtual void set_input(T newValue, uint8_t idx = 0) {
}
+ void connectFrom(ValueProducer<T>* pProducer, uint8_t valueIdx) {
+ pProducer->attach([pProducer, this, valueIdx](){
+ this->set_input(pProducer->get(), valueIdx);
+ });
+ }
+
};
// The following common types are defined using #define to make the purpose of a template class
