@mittwald/react-use-promise
Version:
Simple and declarative use of Promises in your React components. Observe their state and refresh them in various advanced ways.
10 lines (9 loc) • 370 B
JavaScript
import { asyncResourceStore } from "./store.js";
export function refresh(options = {}) {
const { tag, error } = options;
const resourceIsMatchingError = (resource) => error === undefined || resource.isMatchingError(error);
asyncResourceStore
.getAll(tag)
.filter(resourceIsMatchingError)
.forEach((resource) => resource.refresh());
}