Skip to main content

Module requests

Module requests 

Source
Expand description

What views ask for that has to be fetched: the asking, apart from what is asked for.

A view is built from a model it can’t change, and is built again and again. What it finds missing it asks for through Requests::ask, which sends the request down a channel once however often it is asked. A subscription hands what the channel carries to the app, which starts the fetch if Requests::begin lets it: so many are on their way at once, and no more. Only what is on screen is ever built, so only what is on screen is ever asked for.

stateDiagram-v2
    [*] --> Asked: a view finds it missing, and asks
    Asked --> Asked: built again, the view asks again. Nothing is sent twice
    Asked --> InFlight: the app takes it up, and fewer than so many are on their way
    Asked --> [*]: the app takes it up, but it is had already, or too many are on their way
    InFlight --> [*]: fetched, or failed

One that was turned away because too many were on their way is asked for again by the next view that still needs it, which is the next frame if it is still on screen and never if it scrolled away. So nothing is fetched for a row that was only passed by.

The whole road a picture takes, from a row to the web and back, is in crate::guide::flows.

Structs§

Requests
The requests for one kind of thing, each named by a K.

Functions§

subscription
What views asked for through the Requests that inbox receives from, each as the message message makes of it. The app decides which are actually fetched.

Type Aliases§

Inbox
The receiving end of some requests, as the app model keeps it for the subscription that drains it.