import { Peer } from "https://deno.land/x/earthstar@v10.2.2/mod.ts";
Holds many shares' replicas and manages their synchronisation with other peers. Recommended as the point of contact between your application and Earthstar shares.
const peer = new Peer();
peer.addReplica(myReplica);
peer.sync("https://my.server");
Properties
Methods
Begin syncing using an instance implementing ISyncPartner
. Use this if you don't want to sync with a local peer or a server.
Discover other Earthstar peers using a discovery service, for example other peers on the local network.
Returns an asynchronous iterable of DiscoveryEvent
, which describe finding a Peer, another peer initiating sync with you, etc. Some of these events have callbacks which let you initiate sync with the discovered peer.
Fires a given callback whenever the Peer's store of replicas changes.
Fires a given callback whenever a new syncer is added to the peer.