useBatchProgressListener
Packageβ
Installationβ
- npm
- Yarn
- pnpm
npm install @rpldy/uploady
yarn add @rpldy/uploady
pnpm add @rpldy/uploady
Detailsβ
type useBatchProgressListener = BatchCancellableEventHook;
- See: BatchCancellableEventHook
- See: Batch Entity
note
Event Hook - BATCH-PROGRESS
Called every time progress data is received from the upload request(s)
info
This event can be scoped to a specific batch by passing the batch id as a second parameter
Exampleβ
import { useBatchProgressListener } from "@rpldy/uploady";
const MyComponent = () => {
const batch = useBatchProgressListener((batch) => {});
console.log(`batch ${batch.id} is ${batch.completed}% done and ${batch.loaded} bytes uploaded`)
//...
};
Scopingβ
Scoping to an id can be done like so:
//...
const { completed } = useBatchProgressListener("batch-id") || { completed: 0 };
//...