@cogeotiff/fetchable
v7.0.0
Published
Lazyly load data remotely
Downloads
9
Readme
Fetchable
Lazyly load data remotely
import {Fetchable} from '@cogeotiff/fetchable';
const fetched = new Fetchable<string>(() => fetch('https://google.com').then(r => r.text()))
fetched.isFetching // False
fetched.value // null
fetched.error // null
/** Trigger a fetch operation */
const value = await fetched.fetch();
/** Since it has already fetched, returns the cached result */
const valueB = await fetched.fetch();
// Clear the internal cache and refetch the data
fetched.refetch();