SensESP 3.3.0
Universal Signal K sensor toolkit ESP32
Loading...
Searching...
No Matches
sensesp::Observable Class Reference

A base class which allow observers to attach callbacks to themselves. The callbacks will be called when the observable needs to notify the observers about some state change. More...

#include <sensesp/system/observable.h>

Inheritance diagram for sensesp::Observable:
[legend]

Classes

struct  ObserverEntry

Public Member Functions

 Observable ()
 Observable (Observable &&other)
 Move constructor.
void notify ()
int attach (std::function< void()> observer)
 Attach an observer callback.
void detach (int id)
 Remove a previously attached observer by its ID.

Detailed Description

A base class which allow observers to attach callbacks to themselves. The callbacks will be called when the observable needs to notify the observers about some state change.

Definition at line 16 of file observable.h.

Constructor & Destructor Documentation

◆ Observable() [1/2]

sensesp::Observable::Observable ( )
inline

Definition at line 23 of file observable.h.

Here is the caller graph for this function:

◆ Observable() [2/2]

sensesp::Observable::Observable ( Observable && other)
inline

Move constructor.

Definition at line 26 of file observable.h.

Here is the call graph for this function:

Member Function Documentation

◆ attach()

int sensesp::Observable::attach ( std::function< void()> observer)
inline

Attach an observer callback.

Returns
An ID that can be passed to detach() to remove the observer.

Definition at line 40 of file observable.h.

Here is the caller graph for this function:

◆ detach()

void sensesp::Observable::detach ( int id)
inline

Remove a previously attached observer by its ID.

Definition at line 55 of file observable.h.

◆ notify()

void sensesp::Observable::notify ( )
inline

Definition at line 30 of file observable.h.

Here is the caller graph for this function:

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