Template Class ViewSource

Class Documentation

template<class Snapshot, class Change>
class ViewSource

Declaration: final

Retained read/watch access to one Context-owned view source.

Snapshot is synchronized. Watch requires the initialized source’s owner, applies one protected seed before returning, and propagates sizing failures. Ordinary observations use the corresponding typed bus channel instead. Retained source copies own no Context/window/native objects. Closure leaves snapshots readable and rejects new watches without publishing a fake change.

Public Functions

Snapshot snapshot() const

Declaration: [[nodiscard]]

Copy synchronized current state from any thread, including before initialization and after closure.

ViewAttachment watch(std::function<void(const Change&)> callback) const

Declaration: [[nodiscard]]

Attach on the initialized owner; seed runs before return.

Empty callback/foreign owner/closure rejects. A failed seed detaches and propagates. Later required failure prevents dependent runtime work; retain the returned attachment and reset it before releasing borrowed targets.