@cyca/simple-create-resource
TypeScript icon, indicating that this package has built-in type declarations

0.1.0 • Public • Published

@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

Readme

Keywords

none

Package Sidebar

Install

npm i @cyca/simple-create-resource

Weekly Downloads

1

Version

0.1.0

License

MIT

Unpacked Size

15 kB

Total Files

12

Last publish

Collaborators

  • cvpcasada