UNPKG

wxt-zustand

Version:

High-performance Zustand state management for WXT web extensions with seamless cross-tab synchronization and sub-10ms React re-renders

19 lines 889 B
import type { StoreApi } from 'zustand'; import type { StoreConfiguration } from '../types'; import type { RemoteBackendService } from './types'; /** * Set up bidirectional sync between a local Zustand store and the background. * - Local → Background: subscribe to local changes and dispatch full state. * - Background → Local: watch WXT storage and apply remote state. * - Loop prevention: temporarily unsubscribe local listener when applying remote state. * * Uses WXT-native storage.watch for background→local updates * instead of proxy service callbacks for optimal performance. */ export declare function setupBidirectionalSync<S>(storeName: string, store: StoreApi<S>, config?: StoreConfiguration<S>): { service: RemoteBackendService<S>; unsubscribeLocal: () => void; unwatchRemote: () => void; cleanup: () => void; }; //# sourceMappingURL=sync.d.ts.map