Update Notification class to allow for easier reference to the handler type

This commit is contained in:
Matthew Colvin 2023-08-14 20:04:27 -05:00 committed by MatthewColvin
parent 7a9dc1d93d
commit 916f589344

View file

@ -5,16 +5,18 @@
template <class... notifyData> template <class... notifyData>
class Notification{ class Notification{
public: public:
typedef std::function<void(notifyData...)> HandlerTy;
Notification() = default; Notification() = default;
void onNotify(std::function<void(notifyData...)> aHandler); void onNotify(HandlerTy aHandler);
void notify(notifyData... notifySendData); void notify(notifyData... notifySendData);
private: private:
std::vector<std::function<void(notifyData...)>> mFunctionHandlers; std::vector<HandlerTy> mFunctionHandlers;
}; };
template <class... handlerData> template <class... handlerData>
void Notification<handlerData...>::onNotify(std::function<void(handlerData...)> aHandler){ void Notification<handlerData...>::onNotify(HandlerTy aHandler){
mFunctionHandlers.push_back(std::move(aHandler)); mFunctionHandlers.push_back(std::move(aHandler));
} }