replaced function pointer with function object #59
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I'm working on a sensor network projekt, using your excellent Homie framework. I have different sensors (light, temperature), and some actors (led, relay). I modularized my code, so I have a class for every kind of device. And I'm unable to subscribe my HomieNodes to topics when I'm inside of a method.
The problem is, that
HomieNode.subscribe()
only takes a function pointer as a second parameter, which I'm unable to provide. I'd rather give a function object.With this change I'm able to subscribe my method
ledOnHandler()
in one of these two ways:I successfully tested that the old way of doing this still works:
So I don't think that this change breaks anything.
To be honest, I didn't make this change myself. I had a friend helping me, who is far more used to write code in C++. To me, this looks even stranger than usual... ;-)
I'd be happy to learn that there is another way to register, so that this change is obsolete. Please tell me if you know something. Thanks in advance!