ui::Signal¶
Header: winui/core/Property.hpp.
Derives from ui::PropertyBase.
An event with no value, meaning "ask again".
The same edge list as a Property and the same two-way lifetime safety, with no value and so no equality gate: raise() always reaches every observer. A copy (or a move) is a different object with no observers of its own. Assigning to a Signal keeps the observers it has, since they observe this object and not the one it was assigned from. A struct holding one therefore stays an ordinary copyable aggregate.
Example:
ui::Signal settings_changed;
ui::Subscription reload = settings_changed.observe([&] { std::println("Reloading the settings"); });
// Every save raises it, and every raise() runs the handler again, even when nothing in the
// file changed, since a Signal has no value to compare.
window.set_content(ui::Button{.text = "Save", .on_click = [&] { save(); settings_changed.raise(); }});
Signal¶
A signal with no observers.
~Signal¶
Leaves every remaining Subscription dead.
Signal¶
A fresh signal with no observers; other's observers are not copied.
operator=¶
No-op: this signal keeps its own observers.
observe¶
Observe. The returned Subscription must be kept for fn to keep firing.
raise¶
Tell every observer. Const: raising changes nothing a reader of the signal can see, and the objects that own one are handed around by const pointer (a control's ui::CommandRef).
observer_count¶
How many live subscriptions observe this signal.