Skip to content

@statesync/electron


@statesync/electron / ElectronStateSyncBridge

Interface: ElectronStateSyncBridge

Defined in: types.ts:116

The bridge object exposed to the renderer via contextBridge.exposeInMainWorld().

Created by createElectronBridge in the preload script and consumed by renderer-side factories (createElectronRevisionSync, createElectronInvalidationSubscriber, createElectronSnapshotProvider).

Security: This bridge deliberately uses the unsubscribe-return pattern for on because contextBridge proxies break callback reference identity, making removeListener() impossible from the renderer context.

Process context: Defined in preload, consumed in renderer.

Example

ts
// preload.ts
contextBridge.exposeInMainWorld('statesync', createElectronBridge(ipcRenderer));

// renderer.ts
const bridge = (window as any).statesync as ElectronStateSyncBridge;
const sync = createElectronRevisionSync({ bridge, topic: 'todos', ... });

Properties

invoke

ts
invoke: ElectronInvoke;

Defined in: types.ts:129

Invokes a main-process IPC handler on the given channel and returns the result.

See

ElectronInvoke for the full type signature.


on

ts
on: ElectronListen;

Defined in: types.ts:122

Subscribes to IPC events on the given channel and returns an unsubscribe function.

See

ElectronListen for the full type signature and rationale.

Released under the MIT License.