Skip to content

Commit 88f5d2c

Browse files
StartAutomatingStartAutomating
authored andcommitted
docs: WebSocket decoration example ( re #34 )
1 parent eadf4f0 commit 88f5d2c

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

docs/Get-WebSocket.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,25 @@ websocket wss://jetstream2.us-west.bsky.network/subscribe?wantedCollections=app.
118118
}
119119
}
120120
```
121+
We can decorate a type returned from a WebSocket, allowing us to add additional properties.
122+
For example, let's add a `Tags` property to the `app.bsky.feed.post` type.
123+
124+
```PowerShell
125+
$typeName = 'app.bsky.feed.post'
126+
Update-TypeData -TypeName $typeName -MemberName 'Tags' -MemberType ScriptProperty -Value {
127+
@($this.commit.record.facets.features.tag)
128+
} -Force
129+
130+
# Now, let's get 10kb posts ( this should not take too long )
131+
$somePosts =
132+
websocket "wss://jetstream2.us-west.bsky.network/subscribe?wantedCollections=$typeName" -PSTypeName $typeName -Maximum 10kb -Watch
133+
$somePosts |
134+
? Tags |
135+
Select -ExpandProperty Tags |
136+
Group |
137+
Sort Count -Descending |
138+
Select -First 10
139+
```
121140

122141
---
123142

0 commit comments

Comments
 (0)