Skip to main content

useItemProgressListener

Package​

@rpldy/uploady

Installation​

npm install @rpldy/uploady

Details​

type useItemProgressListener = ItemEventHookWithState;
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 };
//...