Skip to content

Commit

Permalink
docs: update usage of subscribe
Browse files Browse the repository at this point in the history
Passing handlers as arguments is deprecated. Observer argument is now passed instead.
  • Loading branch information
RichardIvan authored and insidewhy committed Dec 8, 2021
1 parent fa3b266 commit cc4f9ae
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,27 +67,27 @@ const messages$: Observable<WebSocketPayload> = socket$.pipe(
share(),
)

const messagesSubscription: Subscription = messages.subscribe(
(message: string) => {
const messagesSubscription: Subscription = messages.subscribe({
next: (message: string) => {
console.log('received message:', message)
// respond to server
input$.next('i got your message')
},
(error: Error) => {
error: (error: Error) => {
const { message } = error
if (message === normalClosureMessage) {
console.log('server closed the websocket connection normally')
} else {
console.log('socket was disconnected due to error:', message)
}
},
() => {
complete: () => {
// The clean termination only happens in response to the last
// subscription to the observable being unsubscribed, any
// other closure is considered an error.
console.log('the connection was closed in response to the user')
},
)
})

function closeWebsocket() {
// this also caused the websocket connection to be closed
Expand Down

0 comments on commit cc4f9ae

Please sign in to comment.