Remote / foldkit-remote
foldkit-remote
Server data, cached inside the Foldkit Model. A screen says what it needs; the view gets what the cache knows.
ts
const ProjectPage = App.surface('ProjectPage', {
params: { projectId: Schema.String },
model: ({ params }) => ({ project: Data.get(ProjectSummary, params.projectId) }),
})
RemoteData.render(project, {
loading: () => ProjectSkeleton(),
notFound: () => NoSuchProject(),
failed: error => ErrorView(error),
data: project => ProjectView(project),
})No fetch call, no cache object, no loading flag. While the page is active,
Remote fetches only the fields the Model lacks, stores each entity once, and
hands the view one of six states rather than an undefined. Every result is a
Message through one reducer, so a screen replays from a recorded Model.
Remote is for facts the server owns. An edit the client authors, which
must survive being offline, belongs to foldkit-sync.