async-mqtt-client
async-mqtt-client copied to clipboard
[QUESTION] Use case for multiple callbacks
All callbacks are stored in std::vectors. So multiple callbacks for the same events are possible. I have not had the need to attahc multiple callbacks however. And even then, if I only need a few actions I just use an intermediate function.
I know it is a breaking change, but just storing a std::function instead of a vector-of... would mean slightly faster code and less code. Don't know the effect on RAM.
What is the rationale?
For me also multiple callbacks for the same event stored in vectors is overkill. I don't know if anyone uses multiple callbacks the for the same event. And indeed an intermediate function can perfectly solve this in a rare occasion when multiple callbacks are needed.
Reviving this question.
A problem I have with the vector of callbacks is that it is not straightforward to remove a callback. Not a big problem, but still...
I just started a project using multiple callbacks.
Usecase: different ESP32 use the same functions to publish state and handle OTA-Updater. Therefore on Callback is defined. The ESP32 specific task has its own callbacks and can be added separately.