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 optimised way to work with WebSockets - of course, we don't talk about simple projects, otherwise is much better to use the WebSocket API.
Listening for messages from the server:
Pushing messages to the server:
All these examples have been taken from 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 a safer and better place.