import { Peer } from "https://deno.land/x/earthstar@v10.2.0/src/entries/universal.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
A map of the replicas stored in this peer.
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.
Get all syncers created by this peer. This includes running and cancelled syncers.
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.
The number of replicas held by this peer