Skip to content

Commit cc4f9ae

Browse files
RichardIvaninsidewhy
authored andcommitted
docs: update usage of subscribe
Passing handlers as arguments is deprecated. Observer argument is now passed instead.
1 parent fa3b266 commit cc4f9ae

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

readme.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,27 +67,27 @@ const messages$: Observable<WebSocketPayload> = socket$.pipe(
6767
share(),
6868
)
6969

70-
const messagesSubscription: Subscription = messages.subscribe(
71-
(message: string) => {
70+
const messagesSubscription: Subscription = messages.subscribe({
71+
next: (message: string) => {
7272
console.log('received message:', message)
7373
// respond to server
7474
input$.next('i got your message')
7575
},
76-
(error: Error) => {
76+
error: (error: Error) => {
7777
const { message } = error
7878
if (message === normalClosureMessage) {
7979
console.log('server closed the websocket connection normally')
8080
} else {
8181
console.log('socket was disconnected due to error:', message)
8282
}
8383
},
84-
() => {
84+
complete: () => {
8585
// The clean termination only happens in response to the last
8686
// subscription to the observable being unsubscribed, any
8787
// other closure is considered an error.
8888
console.log('the connection was closed in response to the user')
8989
},
90-
)
90+
})
9191

9292
function closeWebsocket() {
9393
// this also caused the websocket connection to be closed

0 commit comments

Comments
 (0)