SyncChannel namespace exports. Provides a clean API for managing sync channel lifecycle.
import { SyncChannel } from 'happy-opfs';// Worker: start listeningSyncChannel.listen();// Main thread: connect to workerconst result = await SyncChannel.connect(worker);result.inspect(sharedBuffer => { // Iframe: attach to existing channel SyncChannel.attach(sharedBuffer);});// Check if readyif (SyncChannel.isReady()) { ... }// Release the channel when it is no longer neededSyncChannel.disconnect(); Copy
import { SyncChannel } from 'happy-opfs';// Worker: start listeningSyncChannel.listen();// Main thread: connect to workerconst result = await SyncChannel.connect(worker);result.inspect(sharedBuffer => { // Iframe: attach to existing channel SyncChannel.attach(sharedBuffer);});// Check if readyif (SyncChannel.isReady()) { ... }// Release the channel when it is no longer neededSyncChannel.disconnect();
SyncChannel namespace exports. Provides a clean API for managing sync channel lifecycle.
Example