Skip to content

Commit 7065b8b

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

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

docs/_data/Help/Get-WebSocket.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@
7979
"Title": "EXAMPLE 10",
8080
"Markdown": "",
8181
"Code": "websocket wss://jetstream2.us-west.bsky.network/subscribe?wantedCollections=app.bsky.feed.post -WatchFor @{\n {$args.commit.record.text -match \"\\#\\w+\"}={\n $matches.0\n }\n {$args.commit.record.text -match '[\\p{IsHighSurrogates}\\p{IsLowSurrogates}]+'}={\n $matches.0\n }\n}"
82+
},
83+
{
84+
"Title": "EXAMPLE 11",
85+
"Markdown": "We can decorate a type returned from a WebSocket, allowing us to add additional properties.\nFor example, let's add a `Tags` property to the `app.bsky.feed.post` type.",
86+
"Code": "$typeName = 'app.bsky.feed.post'\nUpdate-TypeData -TypeName $typeName -MemberName 'Tags' -MemberType ScriptProperty -Value {\n @($this.commit.record.facets.features.tag)\n} -Force\n\n# Now, let's get 10kb posts ( this should not take too long )\n$somePosts =\n websocket \"wss://jetstream2.us-west.bsky.network/subscribe?wantedCollections=$typeName\" -PSTypeName $typeName -Maximum 10kb -Watch\n$somePosts |\n ? Tags |\n Select -ExpandProperty Tags |\n Group |\n Sort Count -Descending |\n Select -First 10"
8287
}
8388
]
8489
}

0 commit comments

Comments
 (0)