npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@tomsons/react-queue-manager

v0.5.0

Published

React bindings for `@tomsons/queue-manager`. This library provides a React Provider and hooks to seamlessly integrate the powerful queueing capabilities into your React applications.

Readme

@tomsons/react-queue-manager

React bindings for @tomsons/queue-manager. This library provides a React Provider and hooks to seamlessly integrate the powerful queueing capabilities into your React applications.

Features

  • React Provider: A simple <QueueManager> provider to wrap your application.
  • Easy Access via Hooks: useQueueManager to access the core queue manager instance and useTaskHistory to track task progress.
  • Automatic History Tracking: Automatically captures the progress of all enqueued tasks.
  • History Management: Hooks provide functions to clear the entire history or remove individual tasks.
  • Auto-Cleanup: Optional automatic removal of completed or failed tasks from the history after a delay.

Installation

This package has a peer dependency on @tomsons/queue-manager.

# With npm
npm install @tomsons/queue-manager @tomsons/react-queue-manager

# With yarn
yarn add @tomsons/queue-manager @tomsons/react-queue-manager

# With pnpm
pnpm add @tomsons/queue-manager @tomsons/react-queue-manager

How to Use

1. Wrap your App in the Provider

Wrap your application (or the relevant part of it) with the QueueManager provider. You can pass any QueueOptions (like concurrency) as props.

// In your App.tsx or equivalent
import { QueueManager } from '@tomsons/react-queue-manager';
import { MyAppComponent } from './MyAppComponent';

function App() {
  return (
    <QueueManager concurrency={4} maxRetries={3}>
      <MyAppComponent />
    </QueueManager>
  );
}

2. Use the Hooks in your Components

useQueueManager

This hook gives you access to the core QueueManager instance, which you can use to enqueue tasks.

import { useQueueManager } from '@tomsons/react-queue-manager';
import { Task } from '@tomsons/queue-manager';

const MyTaskComponent = () => {
  const queueManager = useQueueManager();

  const handleAddTask = () => {
    const myTask: Task<void> = {
      id: 'my-unique-task-id',
      execute: async () => {
        console.log('Executing task...');
        await new Promise(resolve => setTimeout(resolve, 1000));
      }
    };
    queueManager.enqueue(myTask);
  };

  return <button onClick={handleAddTask}>Add Task</button>;
};

useTaskHistory

This hook provides access to the task history and functions to manage it. It returns an object with history, clearHistory, and removeTaskFromHistory.

import { useTaskHistory } from '@tomsons/react-queue-manager';

const TaskHistoryDisplay = () => {
  const { history, clearHistory, removeTaskFromHistory } = useTaskHistory();

  return (
    <div>
      <h2>Task History</h2>
      <button onClick={clearHistory}>Clear All</button>
      <ul>
        {Object.entries(history).map(([taskId, progresses]) => {
          const lastProgress = progresses[progresses.length - 1];
          return (
            <li key={taskId}>
              {taskId}: {lastProgress.status}
              <button onClick={() => removeTaskFromHistory(taskId)}>Delete</button>
            </li>
          );
        })}
      </ul>
    </div>
  );
};

Provider Props

| Prop | Type | Description | | :--- | :--- | :--- | | concurrency | number | Optional. The maximum number of tasks to run at once. | | maxRetries | number | Optional. The default number of retries for failed tasks. | | defaultRetryPolicy | RetryPolicy | Optional. The default backoff strategy for retries. | | autoClearHistoryDelay | number | Optional. Time in milliseconds to wait before automatically removing a completed or failed task from the history. |

Working Example

A fully functional example demonstrating file uploads with progress bars and history management can be found in the examples/react/queue-manager directory of this repository.

Running unit tests

Run nx test @tomsons/react-queue-manager to execute the unit tests via Vitest.