New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

synctactic

Package Overview
Dependencies
Maintainers
0
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

synctactic

Lightweight one-way background syncing library

latest
Source
npmnpm
Version
0.0.2
Version published
Maintainers
0
Created
Source

Synctactic

Lightweight one-way background syncing library.

Installation

npm i synctactic

Features

  • Sync data from any store to any persistent storage (database, local storage, etc.)
  • Sync only when data changes
  • Force manual sync
  • Disable previous syncs when a new one is triggered
  • Notify when closing the tab and there is a pending sync in the background

Usage

import { sync } from 'synctactic';
import { store } from './store';
import { sendData } from './api';

const { forceSync, unSync } = sync({
  // Subscribe to store changes.
  subscribe: store.subscribe,

  // Sync on store change. Passing an `abortSignal` allows to cancel the sync.
  syncFn: async (abortSignal) => {
    await sendData(store.getState(), abortSignal);
  },

  options: {
    // Debounce time between syncs. Optional. Defaults to `0`.
    wait: 1000,

    // Notify for pending sync on tab close. Optional. Defaults to `false`.
    notifyOnLeave: true,
  },
});

// Triggers a sync.
store.dispatch({ type: 'change' });

// Force a sync manually.
forceSync();

// Stop syncing and cleanup.
unSync();

FAQs

Package last updated on 14 Feb 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts