Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/earthstar/src/entries/universal.ts>Syncer

Storage for private, distributed, offline-first applications.
Go to Latest
class Syncer
Re-export
import { Syncer } from "https://deno.land/x/earthstar@v10.2.0/src/entries/universal.ts";

Syncs the data of a Peer's replicas with that of another peer.

const syncer = peer.sync("https://my.server");

syncer.onStatusChange((newStatus) => {
 console.log(newStatus);
});

await syncer.isDone();

console.log('Sync complete!');

Type Parameters

IncomingTransferSourceType
optional
FormatsType = DefaultFormats

Properties

private
appetite: SyncAppetite
private
bumpingTimeout: BumpingTimeout
private
formats: FormatsArg<FormatsType>
private
heartbeatInterval: number
private
isDoneMultiDeferred: MultiDeferred
private
manager: SyncerManager
private
partnerIsFulfilled
private
statusBus: BlockingBus<SyncerStatus>
private
syncAgentQueues: Map<ShareAddress, AsyncQueue<SyncAgentEvent>>
private
syncAgents: Map<ShareAddress, SyncAgent<FormatsType>>
id
peer: IPeer

Methods

private
addShare(
address: string,
initiateMessaging: boolean,
)

Handle inbound events from the other peer.

cancel(reason?: Error | string)

Stop syncing.

Get the status of all shares' syncing progress.

handleTransferRequest(unnamed 0: { shareAddress: string; formatName: string; path: Path; author: AuthorAddress; source: IncomingTransferSourceType; kind: "upload" | "download"; })

Handle a transfer request which came out of band. This method is mostly used by other syncing APIs.

If the syncer was configured with the appetite: 'once', this promise will resolve when all the partner's existing documents and attachments have synchronised.

onStatusChange(callback: (status: SyncerStatus) => void): () => void

Fires the provided callback whenever any shares' syncing progress changes.