There are so many tutorials over the internet about different JS frameworks, API's and technologies, each day I come across to different JS articles, but almost none of them are about RxJS, even more about WebSockets with RxJs!
These being said, RxJS has the same story, we are used to having it only on Angular projects (for developers who write in Angular - for those who not, I am pretty sure they could never use it) and that's it, I haven't seen any other popular libraries to be implemented it - is it so bad? it weighs so much? it is not reactive enough? I would like to know the answers to these questions 😒.
What would be the reasons of un-exploring these two things, we are going today to see an example of integrating both of them and see that it is not so bad, even more - I see it more efficient and optimized way to work with WebSockets - of course, we don't talk about simple projects, otherwise is much better to use the WebSocket API.
RxJS WebSocket Package
Here I'm going to show just two examples taken from the official documentation page.
Listening for messages from the server:
Pushing messages to the server:
As I said, these examples are taken from the RxJS official documentation WebSocket page, so it is available for everyone. If you are a JS developer and haven't tried RxJS yet, it is time to try it, just give it a try - you will see, it'll worth your time.
Make the internet safer and better place.