-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
5 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3660569
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you are making things more complicated than you need
std::function<void(Event&)>
is already a typed erased function that can wrap any type of function.
is exactly how
std::function<void(Event&)>
is implemented. So when you create a FunctionalEventListener which is a subclass of EventListener you could have just started with std::function<void(Event&)>.3660569
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The implementation choice has to do with the internal usage of the API.
Basically, this implementation forces a named object to be created that can later be used to remove the listener. It enables lamdas to be easily created and the internal implementation remains unchanged.
3660569
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't looked in detail at your internal implementation sorry but since lambda and std::function have become available I have never written functor type objects. Can you point me to the internal code that makes this a requirement?
3660569
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no hard requirement, but this change should offer the way of least resistance. I would be happy to receive an alternate PR if you are able.
3660569
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. Here it is #237