sync

Modern state synchronization and browser storage helpers.

Functions

Function
Description
Example

tab

Sync data between tabs

dphelper.sync.tab(channel, callback)

storageProxy

Auto-syncing localStorage proxy

dphelper.sync.storageProxy(key, defaultValue)

pulse

Low-latency cross-tab event bus

dphelper.sync.pulse(channel, callback)

Description

Cross-tab synchronization:

  • BroadcastChannel - Native browser API for tab communication

  • Storage Proxy - Automatic localStorage synchronization

  • Event Bus - Real-time messaging between tabs

  • Security - Same-origin validation, prototype pollution protection

Usage Examples

Cross-Tab Communication

// Open two tabs and communicate between them

// In Tab 1: Listen for messages
const sync = dphelper.sync.tab('chat', (data) => {
  console.log('Received:', data);
});

// In Tab 1: Send message to other tabs
sync.post({ message: 'Hello from Tab 1!' });

// When done, close the channel
sync.close();

Real-time Updates Across Tabs

Auto-syncing localStorage

With Encryption

Pulse Event Bus

Complete Real-time App

Details

  • Author: Dario Passariello & Jo

  • Version: 0.0.2

  • Creation Date: 20260220

  • Last Modified: 20260221

  • Environment: client (browser)


Automatically generated document

Last updated