|
Aria 2.0.0
C++23 MVVM framework (C++20 minimum) — reactive, coroutine-first, ABI-layered
|
Standard loadable view-model. More...
#include <loadable.hpp>
Public Types | |
| using | value_type = T |
Public Member Functions | |
| LoadState | state () const noexcept |
| bool | is_idle () const noexcept |
| bool | is_loading () const noexcept |
| bool | is_refreshing () const noexcept |
| bool | is_success () const noexcept |
| bool | is_error () const noexcept |
| bool | in_flight () const noexcept |
| True iff a fetch is currently in flight (Loading or Refreshing). | |
| bool | has_value () const noexcept |
| True iff the loadable currently has a value to show (Success, Refreshing, or Error+prior). | |
| bool | has_error () const noexcept |
| True iff an error is currently surfaced. | |
| const T * | value () const noexcept |
| Returns a pointer to the value if has_value(), else nullptr. | |
| template<class U> | |
| T | value_or (U &&fallback) const |
| Returns a copy of the value, or constructs T from fallback if absent. | |
| const Error * | error () const noexcept |
| Returns a pointer to the error if has_error(), else nullptr. | |
| template<class F> | |
| auto | map (F &&f) const -> Loadable< std::remove_cvref_t< std::invoke_result_t< F, const T & > > > |
Static Public Member Functions | |
| static Loadable | idle () noexcept |
| static Loadable | loading () |
| static Loadable | refreshing (T prior) |
| Build a Refreshing state from an existing Success payload. | |
| static Loadable | success (T v) |
| static Loadable | error (Error err) |
| Build an Error state. | |
| static Loadable | error (Error err, T prior) |
Friends | |
| template<class> | |
| class | Loadable |
| bool | operator== (const Loadable &a, const Loadable &b) |
Standard loadable view-model.
Stores up to one value (the freshest known good) and up to one error (the last failure). Combined with state() they encode the five-state view-model.
The class is value-typed and equality-comparable so it composes cleanly with Property<Loadable<T>>'s equality-gated set semantics (per lifecycle.md L-21 and error-model.md E-11). It holds no resources of its own.
| using aria::Loadable< T >::value_type = T |
|
inlinestaticnodiscardnoexcept |
|
inlinestaticnodiscard |
|
inlinestaticnodiscard |
Build a Refreshing state from an existing Success payload.
prior is the value still on display while the refresh runs.
|
inlinestaticnodiscard |
|
inlinestaticnodiscard |
Build an Error state.
If prior is provided the loadable keeps the last good value visible (stale-while-revalidate).
|
inlinestaticnodiscard |
|
inlinenodiscardnoexcept |
|
inlinenodiscardnoexcept |
|
inlinenodiscardnoexcept |
|
inlinenodiscardnoexcept |
|
inlinenodiscardnoexcept |
|
inlinenodiscardnoexcept |
|
inlinenodiscardnoexcept |
True iff a fetch is currently in flight (Loading or Refreshing).
Mirrors AsyncResource's is_loading Property.
|
inlinenodiscardnoexcept |
True iff the loadable currently has a value to show (Success, Refreshing, or Error+prior).
|
inlinenodiscardnoexcept |
True iff an error is currently surfaced.
Only true in Error state (Loading/Refreshing/Success never carry an error per error-model.md – a fresh fetch clears the previous error).
|
inlinenodiscardnoexcept |
Returns a pointer to the value if has_value(), else nullptr.
|
inlinenodiscard |
Returns a copy of the value, or constructs T from fallback if absent.
|
inlinenodiscardnoexcept |
Returns a pointer to the error if has_error(), else nullptr.
|
inlinenodiscard |
|
friend |