Skip to content

Commit 0a12e18

Browse files
committed
Update Jetstream getting started guide
1 parent 91d8b0c commit 0a12e18

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/content/guides/jetstream/introduction/getting-started.mdx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,17 @@ import { Reference } from "../../../../components/markdown/Reference.js";
1414
import { Jetstream } from "@skyware/jetstream";
1515

1616
const jetstream = new Jetstream();
17+
jetstream.start();
1718
```
1819

1920
The `Jetstream` class takes an object parameter with the following properties:
2021

2122
- `wantedCollections`: An array of collections to subscribe to events for. This can contain any collection name or wildcard strings such as `app.bsky.feed.*` to receive events for all collections whose name starts with `app.bsky.feed.`. If not provided or empty, you will receive events for all collections.
2223
- `wantedDids`: An array of DIDs to subscribe to events for. If not provided or empty, you will receive events for all DIDs.
2324
- `cursor`: The Unix timestamp in microseconds to start listening from. A cursor is included in every event emitted as the `time_us` property. If you don't provide a cursor, the class will start listening from the most recent event.
24-
- `endpoint`: The subscription URL of the Jetstream instance to connect to. Defaults to `wss://jetstream.atproto.tools/subscribe`.
25+
- `endpoint`: The subscription URL of the Jetstream instance to connect to. Defaults to `wss://jetstream1.us-east.bsky.network/subscribe`.
26+
27+
To begin listening for events, call the <Reference to="/docs/jetstream/classes/Jetstream#start" type="Method">start</Reference> method.
2528

2629
## Handling events
2730

@@ -47,11 +50,11 @@ import { CommitType } from "@skyware/jetstream";
4750

4851
// Listen for all commits, regardless of collection
4952
jetstream.on("commit", (event) => {
50-
if (event.commit.type === CommitType.Create) {
53+
if (event.commit.operation === CommitType.Create) {
5154
console.log("create in ", event.commit.collection, event.commit.record);
52-
} else if (event.commit.type === CommitType.Update) {
55+
} else if (event.commit.operation === CommitType.Update) {
5356
console.log("update in", event.commit.collection, event.commit.rkey);
54-
} else if (event.commit.type === CommitType.Delete) {
57+
} else if (event.commit.operation === CommitType.Delete) {
5558
console.log("delete in", event.commit.collection, event.commit.rkey);
5659
}
5760
});
@@ -63,7 +66,7 @@ jetstream.on("account", (event) => {
6366

6467
// Listen for identity updates
6568
jetstream.on("identity", (event) => {
66-
console.log("identity update", event.account.did)
69+
console.log("identity update", event.identity.did)
6770
});
6871
```
6972

0 commit comments

Comments
 (0)