Update observable.h
This commit is contained in:
parent
feb4a7ecae
commit
1617fac39f
|
@ -2,6 +2,7 @@
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include "esphome/core/log.h"
|
||||||
|
|
||||||
namespace esphome {
|
namespace esphome {
|
||||||
namespace ratgdo {
|
namespace ratgdo {
|
||||||
|
@ -31,10 +32,13 @@ namespace ratgdo {
|
||||||
void subscribe(Observer&& observer)
|
void subscribe(Observer&& observer)
|
||||||
{
|
{
|
||||||
this->observers_.push_back(std::forward<Observer>(observer));
|
this->observers_.push_back(std::forward<Observer>(observer));
|
||||||
|
ESP_LOGD("XXX","The observers vector is %d in length",this->observers_->size());
|
||||||
}
|
}
|
||||||
|
|
||||||
void notify() const
|
void notify() const
|
||||||
{
|
{
|
||||||
|
ESP_LOGD("YYY","NOTIFY %d subscribers",this->observers_->size());
|
||||||
|
|
||||||
for (const auto& observer : this->observers_) {
|
for (const auto& observer : this->observers_) {
|
||||||
observer(this->value_);
|
observer(this->value_);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue