7.0.0 • Published 3 years ago

@cogeotiff/fetchable v7.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

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();