Listeners.hpp

A class for tracking font event listeners for Widgets.

class Listeners
#include <Listeners.hpp>

Track a set of JavaScript Listeners with their callback IDs.

Public Functions

inline Listeners()
Listeners(const Listeners&) = default
Listeners &operator=(const Listeners&) = default
inline size_t GetSize() const

How many listeners are we tracking?

inline Listeners &Set(const std::string &name, size_t fun_id)

Use a pre-calculated function ID with a new listener.

template<typename ...Ts>
inline Listeners &Set(const std::string &name, const std::function<void(Ts... args)> &in_fun)

Calculate its own function ID with JSWrap.

inline bool Has(const std::string &event_name) const

Determine if a specified listener exists.

inline size_t GetID(const std::string &event_name)

Get the ID associated with a specific listener.

inline const std::map<std::string, size_t> &GetMap() const
inline void Clear()

Remove all listeners.

inline void Remove(const std::string &event_name)

Remove a specific listener.

inline void Apply(const std::string &widget_id)

Apply all of the listeners being tracked.

inline operator bool() const

true/false : do any listeners exist?

Public Static Functions

static inline void Apply(const std::string &widget_id, const std::string event_name, size_t fun_id)

Apply a SPECIFIC listener.

Private Members

std::map<std::string, size_t> listeners

Map triggers to callback IDs.