@cyca/simple-create-resource
Super basic create-resource for use with React Suspense with basic global cache. Note that this doesn't respect HTTP Caching.
This project was bootstrapped with TSDX.
Usage:
// resources.js
import { createResource } from "@cyca/simple-create-resource";
const API = createResource(url => (
fetch(url).then(res => res.json())
);
const FirebaseDoc = createResource(path => (
firebase.firestore().doc(path).get()
))
export { API, FirebaseDoc }
// somefile.js
import { API } from './resources';
API.preload('/thing');
const stuff = API.read('/thing');
API.clear('/thing');
API.clear(); // all keys