Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | 104x 4x 22x 22x 42x | import { PackageCheck } from "shared-utils";
import { getItem } from "@/api/useGetItem";
import { DataPoller } from "./DataPoller";
export type CheckDocumentFunction = (
check: ReturnType<typeof PackageCheck> & { recordExists: boolean },
) => boolean;
export const documentPoller = (id: string, documentChecker: CheckDocumentFunction) =>
new DataPoller({
interval: 1000,
pollAttempts: 20,
onPoll: (data) => {
const check = PackageCheck(data._source);
return documentChecker({ ...check, recordExists: !!data });
},
fetcher: () => getItem(id),
});
|