Data Flow¶
Understanding how data moves through Verity's three layers is crucial to building reliable applications.
Pull Path (Fetching)¶
-
View requests data via framework adapter
-
Verity checks cache
- If fresh, return immediately
- If stale or missing, trigger fetch
-
If in-flight, coalesce request
-
Verity calls registered fetcher
-
Server returns data
-
Verity updates cache and notifies subscribers
-
View re-renders with new data
Push Path (Directives)¶
-
User triggers mutation (button click)
-
Server processes mutation and returns directives
-
View forwards directives to Verity
-
Verity processes each directive
refresh_item: Invalidate + refetch levels in use-
refresh_collection: Invalidate + refetch matching params -
Verity emits directive over SSE to other clients
-
Other clients apply directives (skipping source client)
-
All views converge to same truth
Request/Response Lifecycle¶
Mutation Flow with Directives¶
┌─────────┐ ┌─────────┐ ┌─────────┐
│ View │ │ Verity │ │ Server │
└────┬────┘ └────┬────┘ └────┬────┘
│ │ │
│ onClick="updateStatus" │ │
├─────────────────────────►│ │
│ │ │
│ button shows spinner │ POST /api/invoice/123 │
│ (honest loading) ├─────────────────────────►│
│ │ │
│ │ UPDATE invoice
│ │ EMIT directive
│ │ │
│ │ 200 + directives │
│ ◄─────────────────────────┤
│ │ │
│ button stops spinner │ process directives │
◄─────────────────────────┤ (invalidate + refetch) │
│ │ │
│ │ SSE: directives │
│ │ (fan-out to others) │
│ ├─────────────────────────►│
│ │ │
│ re-render with new data │ │
◄─────────────────────────┤ │
│ │ │
Key Points¶
- Button spinner starts immediately (honest: work is happening)
- No optimistic update (no speculation about server response)
- Server returns directives in mutation response
- Button spinner stops when server responds
- Directives trigger refetch (overlays appear for loud fetches)
- SSE fan-out keeps other clients in sync
- All clients converge to same truth without coordination