Update observable.h

This commit is contained in:
Paul Wieland 2024-08-01 09:09:02 -04:00
parent feb4a7ecae
commit 1617fac39f
1 changed files with 4 additions and 0 deletions

View File

@ -2,6 +2,7 @@
#include <functional>
#include <utility>
#include <vector>
#include "esphome/core/log.h"
namespace esphome {
namespace ratgdo {
@ -31,10 +32,13 @@ namespace ratgdo {
void subscribe(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
{
ESP_LOGD("YYY","NOTIFY %d subscribers",this->observers_->size());
for (const auto& observer : this->observers_) {
observer(this->value_);
}