import { Syncer } from "https://deno.land/x/earthstar@v10.2.0/src/entries/npm.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!');
Constructors
new
Syncer(opts: SyncerOpts<FormatsType, IncomingTransferSourceType>)Type Parameters
optional
FormatsType = DefaultFormatsProperties
private
appetite: SyncAppetiteprivate
bumpingTimeout: BumpingTimeoutprivate
formats: FormatsArg<FormatsType>private
isDoneMultiDeferred: MultiDeferredprivate
manager: SyncerManagerprivate
partner: ISyncPartner<IncomingTransferSourceType>private
statusBus: BlockingBus<SyncerStatus>private
syncAgentQueues: Map<ShareAddress, AsyncQueue<SyncAgentEvent>>private
syncAgents: Map<ShareAddress, SyncAgent<FormatsType>>private
transferManager: TransferManager<FormatsType, IncomingTransferSourceType>peer: IPeer
Methods
private
handleIncomingEvent(event: SyncerEvent)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.
isDone()
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.