Terminality’s reactivity model is built on two templates fromDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/Rikitav/Terminality/llms.txt
Use this file to discover all available pages before exploring further.
terminality:Event and terminality:Property. Event<Args...> is a multi-cast delegate that lets you subscribe to notifications from any code with access to the object. Property<TOwner, T> wraps a value so that assignments automatically notify the owning control to re-measure, re-arrange, or re-render, depending on the InvalidationKind attached to the property. Together they replace manual dirty-flagging and callback registration with a concise, type-safe interface.
Handler<Args…>
A type alias forstd::function<void(Args...)>. Every subscription API accepts a Handler.
Event<Args…>
A multi-cast event. Non-copyable; supports move semantics so it can live inside types that are themselves movable.Constructors and assignment
Event is moved, its internal self-token is updated so that existing EventConnection objects remain valid and still point to the new location.
Subscribing
operator+= — fire-and-forget subscription
operator+= — fire-and-forget subscription
handler with no way to later unsubscribe. Use this when the lifetime of the subscription matches the lifetime of the Event itself (e.g., wiring up a button in the same scope that owns the button):Connect() — RAII subscription
Connect() — RAII subscription
handler and returns an EventConnection that automatically disconnects when it is destroyed. Store the connection as a member variable when you need the subscription to outlive a local scope but stop before the Event is destroyed:Firing
Emit snapshots the handler table before iterating so that handlers that add or remove subscriptions during Emit do not cause undefined behaviour.
EventConnection<Args…>
An RAII handle returned byEvent::Connect. When the EventConnection is destroyed it automatically unsubscribes the corresponding handler. Move-only.
Manual disconnect
Event. Safe to call more than once and safe to call after the Event has been destroyed (the connection holds a weak_ptr to the event’s self-token and checks it before dereferencing).
Lifetime example
conn into a longer-lived container the subscription persists until the container is destroyed:
InvalidationKind
Controls which layout phases are triggered when aProperty value changes.
| Enumerator | Value | Effect |
|---|---|---|
InvalidationKind::None | 0 | No layout pass is triggered. The value is updated silently. |
InvalidationKind::Visual | 1 | Schedules a render pass only. Use for purely cosmetic properties (colors, text content that does not change size). |
InvalidationKind::Arrange | 2 | Schedules arrange + render. Use when the control’s position may change but its measured size stays the same. |
InvalidationKind::Measure | 4 | Schedules measure + arrange + render. Use for any property that can change the control’s desired size. |
Property<TOwner, T>
A value wrapper that ties a typed field to its owning control’s invalidation mechanism.Property is a class template parameterised on the owner type and the value type.
Constructor
| Parameter | Description |
|---|---|
owner | Pointer to the control that owns this property. Must not be nullptr if invalidation or OnPropertyChanged callbacks are needed. |
name | String identifier passed to OnPropertyChanged when the value changes. |
defaultValue | Initial value. Defaults to value-initialisation of T. |
invalidation | Which layout phases to trigger on assignment. |
Setting the value
owner->ApplyInvalidation(invalidation_) and owner->OnPropertyChanged(name_) are called.
Set returns a reference to *owner, enabling fluent chaining:
Reading the value
Property<TOwner, T> directly anywhere a const T& is expected:
Comparison
other, not the Property object itself.
Declaring properties in a control
Properties are declared as data members and initialised in the constructor’s member-initialiser list. Passthis as the owner and pick the narrowest InvalidationKind that is correct for that property:
OnPropertyChanged("Caption") and schedules a full measure pass automatically when Caption changes; it calls OnPropertyChanged("AccentColor") and schedules only a visual refresh when AccentColor changes.