#pragma once #include #include #include namespace esphome { namespace ratgdo { template class OnceCallbacks; template class OnceCallbacks { public: template void operator()(Callback&& callback) { this->callbacks_.push_back(std::forward(callback)); } void trigger(Ts... args) { for (auto& cb : this->callbacks_) cb(args...); this->callbacks_.clear(); } protected: std::vector> callbacks_; }; } // namespace ratgdo } // namespace esphome