class EE::ObservableValue::WeakHandle¶
Overview¶
Non-owning, lifetime-safe access used by adapters such as UIValueBinding. More…
#include <observablevalue.hpp> class WeakHandle { public: // methods bool set(const T& value) const; bool set(T&& value) const; std::optional<T> get() const; Connection observe(Callback callback) const; operator bool() const; };
Detailed Documentation¶
Non-owning, lifetime-safe access used by adapters such as UIValueBinding.
Operations fail harmlessly after the owning ObservableValue is destroyed. A WeakHandle does not make cross-thread access safe.
Methods¶
bool set(const T& value) const
Returns:
true when the owner still exists and accepted the set operation.
bool set(T&& value) const
Returns:
true when the owner still exists and accepted the set operation.
std::optional<T> get() const
Returns:
A copy of the current value, or std::nullopt after the owner expires.
Connection observe(Callback callback) const
Returns:
A scoped observer connection, or an empty connection after owner expiration.