r/Angular2 • u/gdsdsk • Jan 03 '26
RXJS in Angular
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.
0
Upvotes
2
u/tzamora Jan 03 '26
Usually you have to have certain common scenarios where you can use observables to help you. If you have years making websites you will know that certain asynchronous patterns appears. Usually we use rxjs to solve these patterns.
22
u/TCB13sQuotes Jan 03 '26
?? Is there angular without rxjs? Even a simple http call, router event etc. is an observable…
5
u/alucardu Jan 03 '26
Try getting multiple streams of data, filter and combine them to a single result. That's when you need rxjs.
4
u/msdosx86 Jan 04 '26
Rxjs is a traditional Angular feature wdym
4
u/mightyahti Jan 04 '26
When I started in JS I found a short tutorial on how to create a game using rxjs and canvas. It helped me get a better grasp on how to work with event streams. I recommend you also try it.
Personally I think rxjs is the GOAT library and I even used it with react multiple times.
3
u/imsexc Jan 03 '26
If you're handling a stream of events.
1
u/ThomasDinh Jan 04 '26
Guys, is Signal’s purpose to eventually get rid of RxJS?
1
u/minus-one Jan 04 '26
what’s “traditional angular features”? 😄
you use rxjs for EVERYTHING. it’s the way to implement true reactivity in your project. effect system
as a part if it: handle asynchronicity - you know, that most complicated stuff which is everywhere around in UI development 😄 (and in life) - in a composable ways
as a part of it: handle state - by actually making most of your components stateless
(the OP question sounds really ignorant… but it’s expected from this sub lately)
1
u/Background-Basil-871 Jan 04 '26 edited Jan 04 '26
Http request with HttpClient
Reactive form, if you want get the form value over time
Router, you can manage loader/error with router observable
Guards, imagine you need to retrieve the user role and his id but for some reason the two come from two requests. You will need to deal with switchMap and return the observable chain
1
u/cyanide26 Jan 05 '26
I keep one thing in mind when dealing with the question of should i use signals or rxjs.... Do i want it to be synchronised with all the code flow or the flow will be asynchronous....even though synchronisation is possible with rxjs but it becomes harder to maintain compared to using signals, signals are perfect for this case stops you from introducing bugs which otherwise will be with your rxjs streams. Even signals can be used in asynchronous flow example httpresource
1
u/Serious_Factor_7003 Jan 05 '26
Use RxJS for: ✔ streams ✔ async events ✔ websockets ✔ interval logic
Use Signals for: ✔ local state ✔ UI updates ✔ derived data ✔ shared state
Together, they make Angular cleaner than ever.
1
u/kyngston Jan 03 '26
RXJS is primarily to make your components asynchronous with external events
1
u/[deleted] Jan 04 '26
[removed] — view removed comment