Aria 2.0.0
C++23 MVVM framework (C++20 minimum) — reactive, coroutine-first, ABI-layered
Loading...
Searching...
No Matches
reactive.hpp
Go to the documentation of this file.
1#pragma once
2
3// ============================================================================
4// reactive/reactive.hpp
5// ----------------------------------------------------------------------------
6// Single-include umbrella for the Aria reactive subsystem.
7//
8// End users should prefer this header over the individual files: the
9// sub-headers are carefully ordered here so that forward declarations and
10// out-of-line template definitions are all satisfied in one shot.
11//
12// Public surface provided by this header:
13// * reactive::Property<T> -- observable source
14// * reactive::Computed<T> -- derived value (auto-tracked)
15// * reactive::Effect -- side-effect reaction (auto-tracked)
16// * aria::Subscription -- RAII handle returned by observe
17// * reactive::batch / BatchScope -- coalesce multiple writes
18// * reactive::untracked / UntrackedScope -- opt out of tracking
19// * reactive::dep(x) -- explicit dependency declaration
20// * reactive::CircularDependencyError
21//
22// Design rationale: every piece of state that participates in reactivity
23// is a Node in a single process-wide DAG. Writes propagate in two
24// phases (push coloring, pull evaluation) so that computations are
25// evaluated after their upstreams. Reentrant writes can schedule later
26// flush rounds; cycle detection bounds non-converging dependencies.
27// ============================================================================
28
29// Include order matters -- see the notes above each sub-header. In short:
30// graph / node first (they are the protocol), then the three user types,
31// with effect.hpp last because it supplies the out-of-line definitions
32// of Computed's observer methods.
35#include "aria/reactive/graph.inl" // inline implementations of Graph / Node
39#include "aria/reactive/inspector.hpp" // diagnostics: to_dot / to_json / flush tracer
40
41// ============================================================================
42// Public-API promotion
43// ----------------------------------------------------------------------------
44// The implementation lives in `aria::reactive` (an internal namespace),
45// but every user-visible type is promoted into `aria::` via the using
46// declarations below. Per `docs/api-style.md` S-1/S-2, public code MUST
47// use the unqualified `aria::` form -- the `aria::reactive::` qualified
48// names exist only as an implementation locator (e.g. for users who
49// reach into `Graph::assert_on_graph_thread()` for low-level diagnostics).
50// ============================================================================
51namespace aria {
52
60
61using reactive::batch;
63using reactive::dep;
64
65} // namespace aria
RAII batch guard: { BatchScope b; ...; } or use batch([&]{...}).
Definition graph.hpp:346
Thrown when flush detects a dependency cycle.
Definition graph.hpp:63
Definition computed.hpp:86
Definition effect.hpp:127
Lightweight diagnostics entry point.
Definition inspector.hpp:54
Definition property.hpp:103
RAII: within the scope, every dep() behaves like a plain get().
Definition graph.hpp:318
auto batch(Fn &&fn) -> decltype(fn())
Sugar: batch([&]{ firstName = "..."; lastName = "..."; }).
Definition graph.hpp:369
auto untracked(Fn &&fn) -> decltype(fn())
Sugar: untracked([&]{ ... }).
Definition graph.hpp:329
requires ::aria::ReactiveNode< Reactive > void dep(Reactive &r)
Definition computed.hpp:76
Definition signal.hpp:12