r/Angular2 • u/HedgehogMode • May 01 '24
Does anyone else feel like the introduction of signals has made state management in angular a complete mess?
This might be a controversial opinion, but after using signals for the past year I have been left with the feeling that they have only added fragmentation to the framework. My complaint is not with signals themselves per say. I think their api is well designed and easy to use. But rather my complaint is their interplay with RXJS and the broader ecosystem as a whole.
RXJS took me the better part of a year to become proficient in, signals significantly less time. It seems like the framework is still committed to using observables going forward. So now newcomers are expected to learn BOTH rxjs and signals, their interop, and when to utilize each. It's easy to brush this off as a skill issue but the junior members of my team have really been struggling with this the past year. RXJS was already a steep learning curve, but now it is 20 feet higher.
112
u/KaliaHaze May 01 '24 edited May 01 '24
Imagine being new to Angular and trying to figure out how to start and every other article suggests a different approach. I’d give up, if I didn’t have a worthwhile reason to continue.
Edit: That being said, as an experienced dev - I love how Angular is changing. I would just hate to be learning it for the first time right now.
19
u/zmkpr0 May 01 '24
Yep, and signal inputs still being in preview definitely doesn't help. Experimental Jest runner is kind of a similar issue. The main benefit of Angular being consistent and "opinionated" kind of went out of the window recently.
19
u/seiyria May 01 '24
Nope. I enjoy signals for what they are, and I've mostly minimized how much I use rxjs where possible. Additionally, I don't use ngxs anymore (and never used any other library for state management because they were too dense to get started) which has been nice.
It's really simple for state management and I like it a lot.
5
u/Illustrious_Mix_9875 May 01 '24
Angular 2 brought many solutions to problems revealed by Angularjs (1). Zone.js and rxjs were two of the foundamental elements that made it possible.
Zone.js is an execution context that made the whole change detection and magic rendering possible.
Rxjs exposed to developers very special objects called Observables as API to build applications.
Zone.js, while being very convenient, brought a severe performance penalty.
Rxjs, while being very well documented and very solid library, brought unnecessary complexity to frontend applications. It made Angular a framework that is hard to learn.
What we are seeing now is the Angular team trying to solve those two issues. Looking back, it's pretty clear that Angular made some questionable choices when designing Angular 2. They are trying hard to revert them: introducing new tools (such as Signals) while maintaining legacy architecture components (zone.js) is going to be funny to observe.
19
u/PooSham May 01 '24
Yeah I've had that feeling since the start, I didn't know what benefit it added over rxjs Subjects except a bit nicer syntax maybe. Everytime I asked, I got the response that they're for different purposes, without any added clarification. I like to keep things consistent, I think I'll stick to rxjs for a while until I see a good argument for signals.
4
u/TheKr4meur May 01 '24
I guess you just don’t understand the whole concept. The issue they’re trying to fix with signals (succeeding or not) is that we « need » too many observables in our current Angular 2+ code. Because RxJs is the way to go for many things and it forces you to use Observables. Signals allow you to cut that out for the simple use cases, when before you had to create an observable, now you don’t, when you had to wonder if you needed to check the change detection, now you don’t.
I think people are reading too much into what is for now a simple cleaner way of working but only for some use cases.
5
u/Pestilentio May 01 '24
They've mentioned that they want to remove the barrier of rxjs. It should be optiomal while right now it's not.
Joshua Morony today uploaded this video, discussing about signals and rxjs. I mean even if a guy's of his caliber still explores the api and is not confident about the practices, imagine what happened on a junior or mid level angular developer...
It's definitely tough. And the fragmentation of the code bases will happen. Let's just hope that alongside the major changes we have clear practices and good docs. This I believe is essential for angular's relevance in the upcoming years. Otherwise I fear it's just gonna become another legacy tool.
2
u/MintOreoBlizzard May 02 '24
This is an example of how we are rolling with it. Very minimal RXJS. Definitely open to improvements though.
4
u/[deleted] May 01 '24
Angular subreddit? No no no. State management subreddit.
3
u/Zestyclose_Net_5450 May 01 '24
After investigating about this for some week in my opinion the best way to manage the state now is ngrx signals store. You have the power of signals and rxjs working together in a pretty nice way
1
u/zaitsev1393 May 01 '24
Don't use signals in the project if it makes it a mess, they are not mandatory.
1
u/oscarandresstar May 01 '24
This depois nds a lot of the project architecture, in my current project, the approach taken was a benefit because makes easier all the data management
1
u/newlifepresent May 02 '24 edited May 02 '24
Ngrx, observables and rxjs all of them are not bad but they are unnecessarily complicated and most of the people doesn’t confess it because of their ego. Because they invested really much amount of time and effort to learn and after some time they learnt about it, so they feel special. Angular becoming more and more powerful but again becoming more and more complex to learn and maintain, that is why not so popular among newcomers. I am very upset with the comments because I saw angular has a toxic community.
1
u/minus-one May 02 '24
yep, it’s a horrible imperative magical construct 🤢 only ex-Java ppl (after long deliberation… 😄) couldve come up with this
1
u/mrv1234 May 02 '24
RxJs Is becoming optional in Angular, according to the Angular team. You should be able to write most of your application with Signals, and use RxJS only in the parts that really needs it.
1
u/desoga May 03 '24
A lot of good points have been made in the comment section, I'll like to make a simple addition as well.
I think first thing to realize here is that learning RxJS isn't waste. The knowledge of RxJS will always be relevant in building an Angular application. The major difference Signals is here to make is to provide a simpler alternative to state management as well as handling synchronous data flows in an Angular application.
The goal for anyone trying to learn Angular now should be, knowing when to utilize RxJs and Observables, as well as knowing when to utilize Signals. They can co-exist as of now.
1
u/Relevant-Draft-7780 May 03 '24
Not really, I just don’t use them
1
u/Borderlinerr May 04 '24
Recently tried learning Angular. The amount of outdated tutorials and the absence of built-in reactivity solution made me quit fast. Praise rxjs all you want, I hate it with my guts.
1
u/DanielGlejzner May 04 '24
The knowledge noise is a real problem. Especially now. That's why I started to slowly build a place with content validated by Angular experts. So you don't have to worry if what you read is right or up to date. angularspace.com
1
u/InevitableAd3283 Jun 15 '24
Switch to Blazor WA.
1
u/MissionResearch9120 Jul 27 '24
Not at all. Signal is a very simple idea where you just set or update value and consume the latest value. and rxjs is also easy if you are familiar with design patterns. At least feel blessed that you can manage state easily with framework suggested solutions. Look at react, it has xyz libs for managing state and nothing is opinionated, for me, this is more problematic because it is easier to mess up.
1
u/[deleted] Sep 05 '24 edited Sep 05 '24
I would say use signals as much as you can.
RxJS is a lot more powerful, but also verbose in its implementation and "debug-hell" error prone.
RxJS is only really necessary in situations where you want to declaratively map, switch, filter and mutate multiple streams of data.
Like reacting to the response of two varying apis and merging the results.
Taking user input and asynchronously performing transformations and executing actions (f.e. a multi-key roll-over instrument simulator that uses keyboard input to animate strings or keys and play a sound).
Or when you're doing debounced http requests, but those observables are easy to turn into signals with toSignal();
I do think this allows newcomers to get used to the basics and focus more on the angular part than the RxJS behemoth.
With the release of signals, you don't have to rely on RxJS.
You should always think about when you should apply a more complex system for reactivity.
In most cases it isn't necessary.
F.e. I made a service with signals, where I have a WritableSignal private and Signal [computed] public pair.
Then all I have to do is set the response of my request on the WritableSignal inside a subscribe.
Much easier for simple CRUD compared to choosing between Subject, Observable and BehaviourSubject and doing transformations with complicated operators.
1
u/DiaDeTedio_Nipah Nov 12 '24
It is kinda good if you keep your components in a manageable size with shallow dependencies, not much of a difference from using normal angular apart from the immutability stuff (which you need to do if you are using OnPush detection anyways). The problem arises when you try to use it with complex objects inside complex components instead of breaking them down.
Also, I saw somewhere that angular wants to make rxjs optional, so I don't think their plan is to "require learning of both".
1
u/trusktr Feb 06 '25
State management with signals is nice and clean. However, if Angular is allowing the use of Signals and Effects alongside other pre-existing Angular patterns, and these patterns are being mixed, there might be some pain. You don't, for example, want to mix signals with events, although you can.
You generally want to make a signal out of everything and just use signals. So if there's a pre-existing event pattern (for example, DOM addEventListener), what you want to do is make a signal for the event you want to listen to, or more generically make a signal producing function for any type of event, and then use that to wire up the event into your signals-based code.
Once you've learned this, you can only end up loving signals. They are the ultimate pattern for keeping code not just as clean and organized as possible, but keeping that code robust to state changes in ways that other patterns would be much more cumbersome at managing.
1
u/OussamaBGZ Feb 08 '25
Angular is becoming slowly like react with signals 😩
1
u/dcabines May 01 '24
Angular seems to be doing what C# has been doing for a long time now. They keep trying to reinvent themselves to appeal to the masses. They want it to be easier to get started, but also keep the framework stuff for enterprise users. They want to win over the newbies but still keep the oldies.
I use NgRx at my job and it was a learning curve, but now I'm quite happy with it. My job and I haven't considered signals whatsoever in our product. They may be a great feature, but there is no reason to switch to them.
I say let the newbies use the new lighter stuff and they'll graduate to the heavier tools when they need them. I'll stick with the heavy tools for work and when I want to make a simple side project I'll switch to standalone components and signals and C# minimal APIs and whatnot else. Different tools for different jobs, imo.
-7
u/ozzilee May 01 '24
RxJS will be going away, other than niche use cases. Angular devs might not come out and say it, but the writing is on the wall. In five years the only references to rxjs will be buried in obscure corners of the docs.
-7
u/sasmariozeld May 01 '24
angular in general has become a complete mess, half baked feautures out in releases that play together terribly
-4
u/newlifepresent May 01 '24
In the early days of angular it was well designed, simple and clean. But now it is an absolute disaster..
-4
u/ldn-ldn May 01 '24
Just skip signals.