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-native-sync-tasks

v0.1.1

Published

JSI-based task manager for React Native that periodically fetches data from a server, deduplicates responses using hashing, and provides centralized task control via native C++ module.

Readme

🚀 SyncTasksManager (JSI)

SyncTasksManager is a native JSI-based library for React Native that allows you to manage and execute background sync tasks (such as periodic API polling) efficiently from JavaScript, while delegating the actual execution to the native layer for better performance.


⚙️ Features

  • 🔁 Periodic HTTP polling with configurable interval
  • 📡 Callback on data reception or error
  • 🧵 High-performance task execution via JSI
  • 🧠 Centralized task management (start/stop all tasks)
  • ✅ Seamless integration with native modules (C++/JSI)
  • ✨ Built-in response deduplication using response body hash — avoids redundant onData calls if the response has not changed

📦 Installation

npm install react-native-sync-tasks

Don’t forget to run pod install for iOS if using CocoaPods.


🛠️ Usage

import { createTask, SyncTasksManager } from 'react-native-sync-tasks';

type TData = {
  userId: number;
  id: number;
  title: string;
  body: string;
};

const task = createTask<TData>({
  config: {
    url: 'https://jsonplaceholder.typicode.com/posts/1',
    // 2000ms / default 1000ms
    interval: 2000, 
    // headers optional
    headers: {
      'Content-Type': 'application/json',
      'Accept': 'application/json',
    },
  },
  // { body: TData, status_code: number }
  onData: (data) => {
    console.log('DATA', data);
  },
   // { error: string, status_code: number }
  onError: (error) => {
    console.log('ERROR', error);
  },
});

SyncTasksManager.addTask(task);
SyncTasksManager.startAll();
...
// stop all tasks
SyncTasksManager.stopAll();
// or stop only 1 task
task.stop()

🔍 API

createTask<T>(props: CreateTaskParams<T>): Task

Creates a background task that will periodically fetch data from the specified URL.

Params:

| Name | Type | Description | |-----------|----------------------------------------------------------------------|-----------------------------------------------| | config | { url: string; interval: number; headers?: Record<string, string> } | HTTP polling configuration | | onData | (data: { body: T, status_code: number }) => void | Callback when data is successfully received | | onError | (error: { error: string; status_code: number }) => void | Callback when request fails (optional) |

Under the hood, the task stores a hash of the last response body. If the newly fetched response is identical (hash matches), the onData callback will not be triggered.

Task

Represents an individual background sync task.

Methods:

  • start(): void — Manually start the task
  • stop(): void — Stop the task
  • isRunning(): boolean — Check if the task is currently running

SyncTasksManager

A global task manager for controlling multiple tasks at once.

Methods:

  • addTask(task: Task): void — Add a single task
  • addTasks(tasks: Task[]): void — Add multiple tasks
  • startAll(): void — Start all registered tasks
  • stopAll(): void — Stop all running tasks

📄 License

MIT