About
An interface can declare an observable object. This observable will notify observers (callback functions) when a certain event occurs.
Usage
This interface declares the observable "ObservablePing" that will notify observers when the function "Ping" is called:
{
public:
};
Py_ssize_t count
Definition: abstract.h:640
[observers_declaration]
Definition: observers.h:13
MAXON_INTERFACE(ObserveMeInterface, MAXON_REFERENCE_NORMAL, "net.maxonexample.interfaces.observeme")
MAXON_OBSERVABLE(void, ObservablePing,(maxon::Int32 count), maxon::ObservableCombinerRunAllComponent)
int32_t Int32
32 bit signed integer datatype.
Definition: apibase.h:176
#define MAXON_REFERENCE_NORMAL(FREEIMPL)
Definition: interfacebase.h:1173
#define MAXON_METHOD
Definition: interfacebase.h:1001
#define MAXON_INTERFACE_BASES(...)
Definition: objectbase.h:1062
Such a callback function must have the same return value and argument list as defined in the observable declaration:
{
}
Int64 Int
signed 32/64 bit int, size depends on the platform
Definition: apibase.h:188
#define DiagnosticOutput(formatString,...)
Definition: debugdiagnostics.h:176
The observable is accessible by the function of its name. An observer is added with maxon::ObservableBaseInterface::AddObserver():
g_observeMe.ObservablePing().AddObserver(WatchPing)
iferr_return;
#define iferr_return
Definition: resultbase.h:1465
It is also possible to add lambdas to the observable.
g_observeMe.ObservablePing().AddObserver(
{
The observer functions are called when the specific event is triggered.
Further Reading