Exact allows resources and mutations only in the root component, so the read package's data wiring lives in app.contract inside // >>> pkg:read blocks. The convention is described in Package conventions and ownership blocks; this page lists what the read blocks contain and why.
Routes
app.contract L27-L33: the read tab at /, doc "/d/:ref", and inside the read block open-site "/open-site", directory "/dir/:uid", author "/a/:uid". app.json maps the hm protocol to /d/%s, so a deep link arrives as the doc route's parameter (Deep links and URL handling).
Declarations
Name | Kind | Meaning |
|---|---|---|
| state, derive, mutation | The open-site form, see Open a site by URL. |
| state | Bumped by pull to refresh; an argument of every read resource (the epoch). |
| state, task |
|
| state | The directory search text. |
| derive | The stack entries of the read tab. |
| derive | One ref per |
| derive | The ref of the top-most |
| derive | Only the top entry: "Do not request covered detail routes on the visible entry's server." |
| derive | The uid of a visible directory or author entry. |
| derive | The ref of the context document, for the directory's check mark. |
| resource |
|
| resource |
|
| resource |
|
docs is asked for the whole stack at once, which is why every covered document stays loaded and Back shows it instantly. directory and authors get a real uid only while their screen is on top; otherwise the uid is empty and the loaders answer without a request.
The reader's server context
Documents may be read from a server other than the configured one (a typed site, a gateway link). Three pieces keep navigation consistent without changing settings:
docs is called with the configured server; a URL ref makes buildPage switch servers and report the real one in DocPage.server.
readContextServer is that reported server for the visible reader. The directory, authors and the discuss resources are asked on it.
readScopedHref(url, server) rewrites a plain /d/{ref} href to /d/{server}/hm/{ref} (encoded) unless the ref is already a URL. The root's follow action and readDirOpen apply it with readContextServer, so a link tapped inside a typed-site document opens on that site.
A thread entry opened from Activity carries ?from=activity. It counts as a context entry, and a thread entry has no ref parameter (inferred: the context ref is then empty), so the context becomes the configured server; Back restores the covered reader's context. open-site-activity.test.contract asserts readContextServer at each step.
Actions
Action | Effect |
|---|---|
| The open-site form. |
|
|
|
|
|
|
| Push the |
| Set or clear |
| Go back, then |
Provide and view
The root provides discussions, discussNow, discussUtc, readNow and readUtc; read's rows and DocDiscussionSlot inject them instead of threading props through every component.
The view switch renders one screen per stack entry of every tab: DocScreen for read (with ref="", home=true) and doc, then OpenSiteScreen, DirectoryScreen and AuthorScreen in the read block. Each gets active=(e.id == top(nav).id) and loading=pending(...) of its resource. The two DocScreen lines sit just outside the pkg:read view markers, in the lead-owned part of the switch.
Other packages that touch these
Related
The Contract language: resource, derive, task โฆ every and performanceNow()
Do you like what you are reading? Subscribe to receive updates.
Unsubscribe anytime