![]() |
Iridescence 1.00
Embedded Graphic Framework
|
LiveData is an observable data holder class. More...
#include <ds_live_data.h>
Public Member Functions | |
DsLiveData () | |
Default constructor. | |
DsLiveData (const DsLiveData &rhs)=delete | |
DsLiveData & | operator= (const DsLiveData &rhs)=delete |
void | observe (DsView *view, const lambda< bool(T &)> &callback) |
Registers a new observer. | |
void | remove (DsView *view) |
Removes the registered observer. | |
void | invalidate (void) |
Marks the contained data as invalid. The observer callbacks will not be called for updates until the data is valid again. | |
void | post (void) |
Posts the same value again. | |
void | post (const T &value) |
Posts a new value. | |
T & | value (void) |
Returns a reference to the contained value. | |
LiveData is an observable data holder class.
LiveData is aware of the state of an observer class. It only updates the observers that are currently visible on the screen. The observer callbacks are called in the UI thread. The class allows new data to be posted from any thread.
T | Data type |
S | Maximum number of observers. Default is 8. |
|
inline |
Registers a new observer.
view | Pointer to the window providing the visible / hidden status. |
callback | Lambda of type bool(T&) . The parameter T is a reference to the data contained by the LiveData. If the lambda returns true, the live data will be invalidated. No further updates will be sent to the views observing it. This is used for sending one time events to the UI. |
|
inline |
Posts a new value.
value | New value |
|
inline |
Removes the registered observer.
view | Pointer to the DsView class |
|
inline |
Returns a reference to the contained value.
value | Reference of type T |