0.0.1 • Published 3 years ago
last-promise v0.0.1
last-promise
Creates a function which will only ever resolve the promise of the latest function invocation. Useful to avoid updating UI with outdated data when a prior debounced function call resolves after one that was made after.
import { lastPromise } from "last-promise";
const fetchApiResult = lastPromise(() => {
return fetch("https://httpbin.org/status/200");
});
// this will never resolve because the same function is called before it resolved
fetchApiResult();
// this will resolve
fetchApiResult();
0.0.1
3 years ago