Remote / foldkit-remote
How the read loop works
The loop runs one way round:
- A Surface's Projection reads the current cache and declares requirements such as
Project:p1.nameandUser:u7.name. - An active Subscription compares those requirements with the cache and asks
RemoteClientfor missing or stale fields. - The answer returns as a Remote Message.
Data.reducewrites it intoRemote.Model, and the next read of the Model sees the updated fields.
Rendering the same Projection twice keeps reads pure—fetching happens in
Subscriptions outside render, and results enter the Model only through
Data.reduce.
| Piece | Responsibility |
|---|---|
Data.get / live(Data, …) / Data.query | create pure Projections that declare what a consumer needs |
Data.subscriptions | turn requirements of active Surfaces into reads, live streams, and retention roots |
Data.reduce | reduce returned Remote Messages into the application's Remote.Model |
RemoteClient | perform the actual read/query/mutate/live I/O |
One rule keeps the cache coherent: Data.reduce is the only writer. Local
application state changes with modifyFields inside update, like anywhere
else; a server fact only enters the cache as a Remote Message. Never install
cache state with a ref set: requirements, staleness and tombstones stay
consistent only because every fact arrives through the reducer.