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