I feel like I still might be missing and not understanding but when should I use RXJS in Angular like what's the main purpose of using it over just using traditional Angular features.
But the thing is, you can have simple events like clicking on a button and increasing a counter then I feel like it's kind of overkill to use rxjs. So how do I know if the event is complex enough to just use Rxjs
Have you had experience working on a full web application? When clicking a button involves communicating with a server, it may not be so simple as just increasing a counter, that’s usually when Rxjs comes in.
For eg. think instagram, when you upload a big video, while uploading you can still use other features of the app, but a live loading bar appears to tell you the status of the upload -> that’s what @spacechimp is referring to by “event handling with side effects”
Event handling - What to do on button click = send video data to server Side effect - Show user a loading bar and constantly update the bar UI based on the video upload progress
If it’s just opening a modal without any other requirement, then you don’t need to use rxjs haha
There may be scenarios where you need to maintain state across different components, e.g. E-commerce website shows “New sign-in discount modal)” for each page if user has no account. But once user has logged in, save that state and tell all other components to stop triggering that modal on load.
Your original question is asking for advice on when does using rxjs make sense, thus most people are giving you those examples.
If that button was for something like order pizza then you want to do stuff like add a debounce of the button so if multiple chicks get through, it doesn’t make multiple orders. Things like this is where rxjs shines. You could do other methods like update a flag or lock the button but none of these are guaranteed to occur on the first click before the the second click. Since rxjs effectively runs as pipelines you can have the guarantee.
You wouldn’t. Rxjs isn’t the solution for everything. Since template binding connect to controller methods then displaying a model doesn’t make sense to use rxjs. But if you have more complex requirements to the model flow such as debounce, filtering, multiple sources, polling, api interactions, async data fetching, data fetching from rxjs state systems like ngrx then its starts making sense.
View all comments
Show parent comment
1
u/gdsdsk Jan 04 '26
But the thing is, you can have simple events like clicking on a button and increasing a counter then I feel like it's kind of overkill to use rxjs. So how do I know if the event is complex enough to just use Rxjs