Skip to content

Commit fff0344

Browse files
author
James Brundage
committed
docs: WebSocket decoration example ( re #34 )
1 parent 904dbb9 commit fff0344

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

Commands/Get-WebSocket.ps1

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,25 @@ function Get-WebSocket {
8484
{$args.commit.record.text -match '[\p{IsHighSurrogates}\p{IsLowSurrogates}]+'}={
8585
$matches.0
8686
}
87-
}
87+
}
88+
.EXAMPLE
89+
# We can decorate a type returned from a WebSocket, allowing us to add additional properties.
90+
91+
# For example, let's add a `Tags` property to the `app.bsky.feed.post` type.
92+
$typeName = 'app.bsky.feed.post'
93+
Update-TypeData -TypeName $typeName -MemberName 'Tags' -MemberType ScriptProperty -Value {
94+
@($this.commit.record.facets.features.tag)
95+
} -Force
96+
97+
# Now, let's get 10kb posts ( this should not take too long )
98+
$somePosts =
99+
websocket "wss://jetstream2.us-west.bsky.network/subscribe?wantedCollections=$typeName" -PSTypeName $typeName -Maximum 10kb -Watch
100+
$somePosts |
101+
? Tags |
102+
Select -ExpandProperty Tags |
103+
Group |
104+
Sort Count -Descending |
105+
Select -First 10
88106
#>
89107
[CmdletBinding(PositionalBinding=$false)]
90108
[Alias('WebSocket')]

0 commit comments

Comments
 (0)