Skip to main content

useBatchProgressListener

Package​

@rpldy/uploady

Installation​

npm install @rpldy/uploady

Details​

type useBatchProgressListener = BatchCancellableEventHook;
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 };
//...