Flip Reference

DocumentObserverDynamic Class Reference

Declared in


template <class T>   class DocumentObserverDynamic;

flip::DocumentObserverDynamic allows to attach an observer to the document after the document was created.

flip::DocumentObserver has a lifetime longer than the document : it needs to be constructed before the document is constructed, and needs to be destroyed after the document is destroyed.

flip::DocumentObserverDynamic is exactly the inverse : it is constructed anytime after a document is constructed, and is destroyed anytime before the document is destroyed.

A flip::DocumentObserverDynamic takes a document as a parameter, and a document can have any number of dynamic observers at the same time.

Important: flip::DocumentObserverDynamics can and will be called in any order. If you need to order observers, then use composition.

Template Parameters


The root class to observer. T must inherit from flip::Object

Member Functions Synopsys


Constructs the DocumentObserverDynamic

Member Functions


template <class F> DocumentObserverDynamic (Document & document, F f);

Constructs the dynamic document observer, passing the document to observe as well as a callable matching the signature void (T &), typically a lambda function.


using Observer = flip::DocumentObserverDynamic <MyRootClass>;
Observer observer {document, [](MyRootClass & root){
   if (root.changed ())
      // ...