Empirical
Public Member Functions | Static Public Member Functions | List of all members
emp::web::Listeners Class Reference

Track a set of JavaScript Listeners with their callback IDs. More...

#include <Listeners.h>

Public Member Functions

 Listeners ()
 
 Listeners (const Listeners &)=default
 
Listenersoperator= (const Listeners &)=default
 
size_t GetSize () const
 How many listeners are we tracking? More...
 
ListenersSet (const std::string &name, size_t fun_id)
 Use a pre-calculated function ID with a new listener. More...
 
template<typename... Ts>
ListenersSet (const std::string &name, const std::function< void(Ts...args)> &in_fun)
 Calculate its own function ID with JSWrap. More...
 
bool Has (const std::string &event_name) const
 Determine if a specified listener exists. More...
 
size_t GetID (const std::string &event_name)
 Get the ID associated with a specific listener. More...
 
const std::map< std::string, size_t > & GetMap () const
 
void Clear ()
 Remove all listeners. More...
 
void Remove (const std::string &event_name)
 Remove a specific listener. More...
 
void Apply (const std::string &widget_id)
 Apply all of the listeners being tracked. More...
 
 operator bool () const
 true/false : do any listeners exist? More...
 

Static Public Member Functions

static void Apply (const std::string &widget_id, const std::string event_name, size_t fun_id)
 Apply a SPECIFIC listener. More...
 

Detailed Description

Track a set of JavaScript Listeners with their callback IDs.

Constructor & Destructor Documentation

emp::web::Listeners::Listeners ( )
inline
emp::web::Listeners::Listeners ( const Listeners )
default

Member Function Documentation

void emp::web::Listeners::Apply ( const std::string &  widget_id)
inline

Apply all of the listeners being tracked.

static void emp::web::Listeners::Apply ( const std::string &  widget_id,
const std::string  event_name,
size_t  fun_id 
)
inlinestatic

Apply a SPECIFIC listener.

void emp::web::Listeners::Clear ( )
inline

Remove all listeners.

size_t emp::web::Listeners::GetID ( const std::string &  event_name)
inline

Get the ID associated with a specific listener.

const std::map<std::string, size_t>& emp::web::Listeners::GetMap ( ) const
inline
size_t emp::web::Listeners::GetSize ( ) const
inline

How many listeners are we tracking?

bool emp::web::Listeners::Has ( const std::string &  event_name) const
inline

Determine if a specified listener exists.

emp::web::Listeners::operator bool ( ) const
inline

true/false : do any listeners exist?

Listeners& emp::web::Listeners::operator= ( const Listeners )
default
void emp::web::Listeners::Remove ( const std::string &  event_name)
inline

Remove a specific listener.

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

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

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

Calculate its own function ID with JSWrap.


The documentation for this class was generated from the following file: