Skip to content

Commit

Permalink
Edit CHANGELOG and README for discovery features
Browse files Browse the repository at this point in the history
  • Loading branch information
sgwilym committed May 16, 2023
1 parent c6d5896 commit 18f85b6
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Changelog

## next
## v10.2.0

This is a feature release adding APIs to **automatically discover and sync with
peers on the local network**.

- (Feature) Added `Peer.discover`, a new method for automatically discovering
other peers. How it does that it left to the `DiscoveryService` you provide
Expand Down
23 changes: 22 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ import * as Earthstar from "earthstar";
// Node and browser APIs are namespaced in the NPM distribution:
import { ReplicaDriverWeb } from "earthstar/browser";
import { ReplicaDriverSqlite } from "earthstar/node";

```

We recommend the browser and Deno versions. This module has been built with many
Expand Down Expand Up @@ -361,6 +360,28 @@ const allDocsWithAttachments = await replica.addAttachments(allDocs);
`attachment` property. The type of this property will either be `DocAttachment`,
`undefined`, or `ValidationError`.

## Discovering other peers on the local network

Earthstar is able to automatically discover other Earthstar peers on the same
network, and in turn advertise itself to others.

```ts
const discoveryLan = new DiscoveryLAN({ name: "My Computer" });

for await (const discoveryEvent of peer.discover(discoveryLan)) {
if (discoveryEvent.kind === "PEER DISCOVERED") {
discoveryEvent.sync();
}
}
```

> On Node, the `DiscoveryLAN` API is exported from "earthstar/node".
>
> On Deno, this feature uses unstable APIs and is not included with the default
> module exports. It can be imported from
> `https://deno.land/x/earthstar/src/discovery/discovery_lan.ts`. Usage also
> requires the `--unstable` flag.
## Subscribing to replica changes

There are many ways to subscribe to the many events a replica generates during
Expand Down

0 comments on commit 18f85b6

Please sign in to comment.