Portals0.7.0 · dev (544a5c68c72e · 2026-11-28 UTC)
Loading...
Searching...
No Matches
portals::CheckStateBinding Class Reference

Own one checkbox's action, subscription and shared UI model owner. Tree, router and scheduler must outlive this token; destroy/move on UI between frames, including from its callback. Model changes never invoke the business callback. Call sync before each frame after external changes/draining events: notifications can be rejected, and equal Property::set does not retry them. Latest committed value wins. More...

#include <controls.hpp>

Public Member Functions

 ~CheckStateBinding ()
 Disconnect subscription/action and release model ownership on UI. Admitted callbacks retain their captures; router collection may defer the final model release. Wrong-thread subscription destruction terminates rather than throwing.
 CheckStateBinding (CheckStateBinding &&) noexcept
 Transfer all ownership from the unnamed source binding argument on UI. The source becomes empty; its sync returns INVALID_ARGUMENT and destruction is harmless. No callbacks run during this nonthrowing transfer.
CheckStateBinding & operator= (CheckStateBinding &&) noexcept
 Replace ownership from the unnamed source binding argument on UI; self-move is a no-op. The source becomes empty. All replacement fields are installed before retiring old resources; deferred capture reclamation can reenter UI code. Neither binding owns its tree/router.
 CheckStateBinding (const CheckStateBinding &)=delete
CheckStateBinding & operator= (const CheckStateBinding &)=delete
std::expected< void, TreeError > sync ()
 Read the latest committed model snapshot on UI between frames and synchronize presentation.

Friends

std::expected< CheckStateBinding, TreeError > bindCheckbox (WidgetTree &tree, EventRouter &router, Node< CheckBox > node, std::shared_ptr< Property< CheckState > > model, std::function< void(CheckStateResult)> changed, CheckBoxOptions options={})
 Bind an explicit checkbox state on UI, preserving Property commit receipts.

Detailed Description

Own one checkbox's action, subscription and shared UI model owner. Tree, router and scheduler must outlive this token; destroy/move on UI between frames, including from its callback. Model changes never invoke the business callback. Call sync before each frame after external changes/draining events: notifications can be rejected, and equal Property::set does not retry them. Latest committed value wins.

Member Function Documentation

◆ operator=()

CheckStateBinding & portals::CheckStateBinding::operator= ( CheckStateBinding && )
noexcept

Replace ownership from the unnamed source binding argument on UI; self-move is a no-op. The source becomes empty. All replacement fields are installed before retiring old resources; deferred capture reclamation can reenter UI code. Neither binding owns its tree/router.

Returns
This binding by reference; callers must not use the result if reentrant cleanup destroyed its owner.

◆ sync()

std::expected< void, TreeError > portals::CheckStateBinding::sync ( )

Read the latest committed model snapshot on UI between frames and synchronize presentation.

Returns
Success with paint invalidation only on a value change; INVALID_ARGUMENT for a moved-from token, WRONG_THREAD from the model/tree, or the tree's WRONG_SESSION, STALE_NODE, closed, WOULD_BLOCK (active frame), CALLBACK_FAILED or invalidation error. Rejected notifications do not prevent resynchronization.
Note
No business callback runs; old queued notifications cannot overwrite a newer committed value.

◆ bindCheckbox

std::expected< CheckStateBinding, TreeError > bindCheckbox ( WidgetTree & tree,
EventRouter & router,
Node< CheckBox > node,
std::shared_ptr< Property< CheckState > > model,
std::function< void(CheckStateResult)> changed,
CheckBoxOptions options = {} )
friend

Bind an explicit checkbox state on UI, preserving Property commit receipts.

Parameters
treeBorrowed UI tree; outlives binding, model and router.
routerBorrowed router for tree; existing eligibility/admission rules apply.
nodeObserving live checkbox identity.
modelRequired shared UI model; invalid committed enum values are rejected by sync/input.
changedRequired owning activation callback; receives one exact receipt, even on failure.
optionsOwning cycle policy; invalid policy returns INVALID_ARGUMENT.
Returns
Scoped binding or existing TreeError registration/synchronization errors; INVALID_ARGUMENT for null model, empty callback or invalid enum values. No business callback on external updates.
Note
Tree/router/scheduler outlive the UI-affine token. Admitted callbacks survive self-removal. Call sync before frames to recover rejected notifications. Equal values never repaint or republish. Callback exceptions become CALLBACK_FAILED through routing and cannot undo a committed model value.

The documentation for this class was generated from the following file: