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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@technogise/rn-background-queue-processor

v2.0.0

Published

Library which creates a background queue processor for react native apps.

Downloads

11

Readme

CircleCI Coverage Status npm version

React Native Queue Processor

A package with the help of which users will be able to add and process different kind of jobs in a queues with background persistent queue processing

Prerequisite

This package does not have any prerequisites that need to be installed.

Features

  • A React Native Queue Processor with persistent queues using rn-background-queue-processor-realm-adapter
  • Jobs will be executed according to priorities using the queues.
  • Job will retry until the failed count matches job's number of retry attempts with retryInterval.
  • Has functionality for Worker instances as well.
  • Background Persistent queue processing using WorkManager.
  • It also plays well with Workers so your jobs can be thrown on the queue, then processed in dedicated worker threads for improved processing performance.
  • Failed Jobs can also be processed.

Compatibility

While we ensure to keep the library updated with newer and improved upcoming releases for React Native, our current version works well for React Native: v0.62.1

Installation steps

npm i @technogise/rn-background-queue-processor

Usage

constructor(dbAdapter) {
         this.adapter = dbAdapter;
     }

The dbAdapter here is an additional feature with which we enable our developers to use this queue with any db of their choice.

  • enqueue(job): Enqueues the job in the queue

  • dequeue(): Dequeues the job from queue on successful execution

  • peek(): To get the top job from Queue

  • getSize(): Returns the length of Queue

  • getItems(): Gives all items of Queue

  • failedJobsEnqueue() Enqueue all the Failed Jobs for processing

  • Adapter

    It is an abstract class which needs to be implemented by users of this package for easy use of any database for storing and processing the queues.

    For the easier understanding and reference, we have added an InMemoryAdapter.js. Here is a list of all functions available in the Adapter class which can be used,

    • getAllItems(): To get all jobs in current queue
    • remove(): Method to remove a job from current queue
    • addItem(item): Method to add a job in the current queue
    • getLength(): Method to get length of current queue
    • getTopItem(): Method to get the current job for processing
    • addFailedItems() Method to add failed items
  • Job While Job class has methods to get id, name and param of current job, we have made the execute, jobSuccess and jobFail function to be abstract for the developer so that he/she decides what to do on execute call.

    The execute method can be used for performing the action in current job. For example, if the current job is an API call then developer can add the steps to fetch data from API in this execute ,method.

    The jobSuccess method tells the developer defined action that needs to be taken if the API response is 200.

    The jobFail method tells the developer defined action that needs to be taken if the API response is 4XX.

  • Worker

    Worker class is a singleton class. In this class, user can process queue using process()

  • Communication with native

    • Process function in worker class schedule a job(STARTPROCESSINGJOB) which calls native module
    • Native module emits events which are listened on the Js side, based on the event emitted queueProcessor will start processing.

Made with :heart: from Technogise

You can explore our other works on GitHub