react-suspense-fetch
React Suspense Render-as-You-Fetch pattern for REST APIs.
The new Render-as-You-Fetch pattern is mind-blowing. So far, only Relay implemented that pattern for GraphQL. This library aims at implementing that pattern for REST APIs.
This is a highly experimental project. Everything will change.
Install
Usage
API
prepare
Create a new suspendable result from fetchFunc.
The result is mutable and can be run later just once.
It will suspend forever unless run() is called.
Type: Prepare
Parameters
fetchFunc
FetchFunc<Result, Input>transformFunc
TransformFunc<Input, Source>?
Examples
run
Run the prepared suspendable result.
Parameters
result
Prepared<Result, Input>input
Input
Examples
prefetch
Create a new suspendable result and run fetchFunc immediately.
Type: Prefetch
Parameters
fetchFunc
FetchFunc<Result, Input>inputOrSource
(Input | Source)transformFunc
TransformFunc<Input, Source>?
Examples
Examples
The examples folder contains working examples.
You can run one of them with
and open http://localhost:8080 in your web browser.
You can also try them in codesandbox.io:
01
02
03
04
05