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

paragon-sync-client

Package Overview
Dependencies
Maintainers
3
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

paragon-sync-client

[![Build status](https://ci.appveyor.com/api/projects/status/6ouu83o029dybq5a?svg=true)](https://ci.appveyor.com/project/Paragon/sync-client)

latest
npmnpm
Version
0.0.14
Version published
Weekly downloads
16
Maintainers
3
Weekly downloads
 
Created
Source

Paragon Client Synchronization Library

Build status

This library enables synchronising the state of a redux app across multiple clients. It works with sync-server to distribute the state using a master client and then replicate every redux action across all connected clients.

Installing

  • npm install --save-dev paragon-sync-client

Example

Check out the sync-client-demo repository for a proof-of-concept redux app using this library.

// Creating an instance of SyncClient begins the process of connecting to the server and preparing
//   to receive remote actions
const client = new SyncClient({
   // The websocket url of a running sync-server
  serverUrl: 'ws://localhost:9090',

  // State will be synchronized with all other clients in the specified room
  room: 'pdf-client.job.42', 

  // (optional): you can whitelist only the actions that should be synchronized.
  synchronizedActions: ['SOMETHING_HAPPENED', 'SOMETHING_ELSE_HAPPENED'],

  // (optional): you can whitelist only the parts of state that should be synchronized.
  //   Currently if you whitelist any part of the state you must also whitelist every action that might
  //   cause that state to change.  However this will become more flexible in the future.
  synchronizedState: [
    'annotations.annotationData',
    {
      documents: ['pdfData', 'pdfCount']
    }
  ]
});

// Wrap the application's root reducer using `synchronizedReducer`, and make sure to install 
//   the sync middleware into your redux store
const reduxStore = createStore(createSynchronizedReducer(rootReducer), client.middleware);

// After the store is created using the synchronized reducer and middleware, call #synchronize
//   to begin synchronizing it with any other clients in the specified room
client.synchronize(reduxStore);

// The connect event will fire as soon as a successful connection has been made to the synchronization server
client.on('connect', () => {
  // If possible, it's helpful to load the redux store's initial state from the master client to
  //   ensure consistency
  if (client.hasMaster) client.loadInitialStateFromMaster();
});

FAQs

Package last updated on 18 Oct 2018

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