Handling WebSocket connections
WebSocket is a communication protocol that provides us with real-time communication with client and server. The difference between WebSocket and HTTP is that the former is a two-way communication, where both sides can continuously send data, which is perfect for real-time applications such as chat apps, multiplayer gives, live notifications, IoT apps, and so on.
RxJS provides us with a webSocket
factory function, a wrapper around the W3C-compatible WebSocket object provided by the browser.
How to do it…
In this recipe, we are going to explore a reactive approach for handling real-time updates over WebSocket by building a small cooking recipe app. We will load a list of recipes from the mocked BE (using MSW) over a WebSocket connection and show them in the list. Also, we will automatically update the list over WebSocket if there is a new data entry. Additionally, we will implement a heartbeat mechanism, which is essential when we lose...