Skip to main content

useRetryListener

Package​

@rpldy/retry-hooks

Installation​

npm install @rpldy/retry-hooks

Details​

type RetryEventData = {
items: string[];
options: UploadOptions | void;
};

type RetryEventCallback = (data: RetryEventData) => void;

type useRetryListener = (cb: RetryEventCallback) => void;;
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

info

To enable retries for your Uploady instance, you need to use the provided (uploader enhancer): retryEnhancer.

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 };
//...