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 🙏

© 2026 – Pkg Stats / Ryan Hefner

react-task-runner

v1.0.5

Published

An asynchronous task runner built on react and redux.

Readme

A client side task runner for react and react-native applications.

Purpose

react-task-runner performs asynchronous tasks in the background of a react or react-native application.

Installation

npm install react-task-runner

Run a Test App

Dependencies

The Test app is a react native application. You will need to follow react-native getting started if you don't have react-native setup already.

Clone, install & Run

git clone https://github.com/willbenmitch/react-task-runner.git

cd TaskRunner && npm install

cd TestApp && npm install

npm start

Basic Usage

The intended usage is to render the <TaskRunner /> component at the top level of where you would like tasks to be run. TaskRunner accepts two properties a list of queueNames (unique strings to identify your different task queues), and storage (where you intend to store the tasks in between app sessions - should be LocalStorage for react or AsyncStorage for react-native).

    import { AsyncStorage } from 'react-native'
    const queueNames = ['DataUploads', 'VideoUploads'] // queueNames is an array of strings that uniquely identify your queues. Name them whatever you'd like.

    <TaskRunner queueNames={queueNames} storage={AsyncStorage}>
        {/* render your Queues here */}
    </TaskRunner>

Inside TaskRunner you should render individual Task Queues using the Queue component. The structure of Queue is as follows:

    <Queue
        queueName={'DataUploads'}
        onAction={this.handleAction}
        onDone={this.handleDone}
        onFailed={this.handleFailed}
    />

Example

App.js

import React from 'react'
import { StyleSheet, Text, View, TouchableOpacity, AsyncStorage } from 'react-native'

import TaskRunner, { addTask, PENDING, clearQueue, getQueue } from 'react-task-runner'
import type { Task } from 'react-task-runner'

import Test from './Test'

const queueNames = ['TEST']

type State = {
    success: number,
    counter: number,
    failed: number,
}

export default class App extends React.Component<{}, State> {
    state = {
        success: 0,
        counter: 0,
        failed: 0,
    }

    handleDone = (count: number) => {
        const queue = getQueue('TEST')
        const counter = queue.filter(item => !item.err).length
        this.setState(state => ({ counter, success: state.success + 1 }))
    }

    handleFailed = (task: Task) => {
        const queue = getQueue('TEST')
        const counter = queue.filter(item => !item.err).length
        const failed = queue.filter(item => item.err).length
        this.setState({ counter, failed })
    }

    handleAdd = () => {
        const id = (Math.random() * 100000).toString()
        addTask('TEST', { id, status: PENDING })
        const queue = getQueue('TEST')
        const counter = queue.filter(item => !item.err).length
        this.setState({ counter })
    }

    render() {
        return (
            <View style={styles.container}>
                <Text style={{ fontSize: 30 }}>Queue: {this.state.counter}</Text>
                <Text style={{ fontSize: 30 }}>Success: {this.state.success}</Text>
                <Text style={{ fontSize: 30 }}>Failed: {this.state.failed}</Text>

                <TouchableOpacity onPress={this.handleAdd} style={{ margin: 40 }}>
                    <Text>Add Task!</Text>
                </TouchableOpacity>

                <TaskRunner queueNames={queueNames} storage={AsyncStorage}>
                    <Test onDone={this.handleDone} onFailed={this.handleFailed} />
                </TaskRunner>
            </View>
        )
    }
}

const styles = StyleSheet.create({
    container: {
        flex: 1,
        backgroundColor: '#fff',
        alignItems: 'center',
        justifyContent: 'center',
    },
})

Test.js

// @flow
import * as React from 'react'

import { queue } from 'react-task-runner'
import type { Task } from 'react-task-runner'

type Props = {|
    onDone: number => void,
    onFailed: (task: Task) => void,
|}

type State = {
    counter: number,
}

export default class Test extends React.PureComponent<Props, State> {
    counter = 0

    handleAction = (task: Task): Promise<Task> =>
    // mimic an async task
    // onAction expects a promise to be returned
        new Promise((resolve, reject) => {
            setTimeout(() => {
                this.counter += 1
                if (Number(task.id) > 50000) {
                    resolve(task)
                    return
                } else {
                    reject(task)
                    return
                }
            }, 2000)
        })

    handleDone = () => {
        // method to perform when task is done
        // task is automatically removed from queue on completion
        this.props.onDone(this.counter)
        }

    handleFailed = (task: Task) => {
        // handle task failure
        // typical actions would be  retryTask, removeTask, or clearQueue 
        this.props.onFailed(task)
        }

    render() {
        return (
            <Queue
                queueName={'TEST'}
                onAction={this.handleAction}
                onDone={this.handleDone}
                onFailed={this.handleFailed}
            />
        )
    }
}