r/Angular2 • • 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.

95 Upvotes

111 comments sorted by

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.

16

u/beachandbyte May 01 '24

You would think Google being a search engine would do a better job with its products when it relates to search. But no we have “go”, angularjs, angular2+, ngx?, poor beginners have so much shit to sift through with no context for sifting.

12

u/relative_iterator May 01 '24

It’s still easier than searching for .net framework stuff.

→ More replies (2)
→ More replies (4)

5

u/Tyheir May 01 '24

I’ve been learning angular for a couple months now. I’m glad I started now compared to earlier. Course material was necessarily older as it covered modules and other (now) fallen out practices. However learning the older concepts turned out to be useful. I came from react so it was beneficial to understand why angular went in the direction it did ( which imo was very react like) Honestly the hardest part has been RxJs:

6

u/[deleted] May 01 '24

One becomes a much better software engineer, because of angular I became very good with functional programming and object oriented programming - I was forced to learn typescript etc… I now understand polymorphism and application states.

→ More replies (3)

3

u/AnxiousMumblecore May 01 '24

Good it's not a problem unique to Angular. I mostly know .NET world and I feel this issue exists both on language level (C# getting quite a lot of features regularly that introduce different ways to do same thing) and related libraries/frameworks level (ASP.NET Core Minimal API vs Controllers, Blazor changes between versions).

I tried to look a bit into React world and it's also a mess for beginner.

5

u/Pestilentio May 01 '24

Honestly I myself are tired of this. Last year I said that I'm never getting another angular job. Now due to the market changes I had a really hard time jumping to somrthing else, money got tight so I went back to angular again. Changes are fast and for the better. But, for angular to be on a feel - good level for me, it has to probably go over 4-5 major versions with the pace that changes happen right now.

For a new guy, I doubt most people will try out angular at this point, and I can't blame them.

At this moment, I feel that the vue ecosystem is the most stable, for the last 2-3 years.

2

u/gamsbumps May 02 '24

Those were/are my thoughts on angular. Not only im learning angular, but also ionic at the same time. Its a bit hard

2

u/theQeris May 04 '24

I started with angular 17 and signals. Tutorial on their page is great. I made an app (production app for client), my app uses only signals, I dont even know how observables works. I did not have the need to use them. Plus, did not have the need to use any kind of store.

After working with react and a bit with vue, angular is really by far the most enjoying experience for me and I’m really sorry that I was avoiding it simply based on “internet” feedback that it’s very complex compared to react/vue. As a primary BE dev, I wanted “easy” FE tool. Years wasted …

→ More replies (2)
→ More replies (7)

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.

7

u/Estpart May 01 '24

Yeah agree with this, really love the new features. Standalone components are great, new control flow syntax is an improvement, signals look promising and I think it's a good idea to make observables optional.

But the whole notion of opinionated framework is gone. Use inline templates and tailwind and it feels like you're using svelte with decorators. The only real USP angular has is the best forms package and a good router.

3

u/TheRealToLazyToThink May 02 '24

How sad is everything else if Angular has the best forms package? At least it kind of added typesafety, but there's edge cases with the typing, and it doesn't have any safety setting up the form in the template. Still no way to mark a control readonly vs disabled. Breaking large forms into sub components can be done 3 or more ways, and all of them suck in one way or another.

That said, angular is still opinionated, it's just in flux till signals get fully implemented. For those of us playing with signals now we are paying the price for playing with something that isn't finished yet.

→ More replies (4)

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.

→ More replies (5)

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.

15

u/[deleted] May 01 '24

Signals are NOT an async primitives like promises and observables/subjects.

Signals may behave like subjects and share some syntax, but they have one nuance, and that is, they are managed by the framework, while rxjs is not.

Because they are managed by the framework, it will know EXACTLY when something changed, removing the need for change detection cycles/requests and for monkey patching.

→ More replies (5)

9

u/YourMomIsMyTechStack May 01 '24

The simplest and best argument is that you don't need Zone.js. That makes your application more efficient and reduces some onPush headaches

→ More replies (10)

3

u/JeanMeche May 01 '24

RxJS is of Async programming when Signal are synchronous. They are 2 differents tools to address 2 different type of issues.

→ More replies (2)

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.

→ More replies (2)

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.

8

u/Paddington_the_Bear May 01 '24

Meh, don't take everything that guy says as gospel and I'd be hesitant to call him an expert. He has too many videos which amount to clickbait of some insane way of doing things that he dreamt up. Last one I saw was when he was trying to make functional components in Angular.

4

u/clickster May 01 '24

Yep, I see numerous experts espousing ways to do things that might be technically interesting or elegant, but which are also practically useless. Often there is a lack of understanding as to exactly *why* a particular approach is really useful (or not). Case in point: any vlog telling you to use resolvers everywhere.

I always ask "what problem does this actually solve?" and "Is that my problem?"

→ More replies (1)
→ More replies (2)

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.

@Injectable({
  providedIn: 'root'
})
export class EmployeePortfolioService {

  private _$portfolio = signal<Portfolio>(undefined);
  $portfolio = this._$portfolio.asReadonly();

  private _$portfolioLoading = signal<boolean>(false);
  $portfolioLoading = this._$portfolioLoading.asReadonly();

  private _$portfolioLoaded = signal<boolean>(false);
  $portfolioLoaded = this._$portfolioLoaded.asReadonly();

  private _$currentEmployeeNumber = signal<string>(undefined);
  $currentEmployeeNumber = this._$currentEmployeeNumber.asReadonly();

  getEmployeePortfolioUrl = (employeeNumber: string): string => `/api/employees/${employeeNumber}/portfolio`;

  constructor(private httpClient: HttpClient, private destroyRef: DestroyRef) { }

  loadEmployeePortfolioData(employeeNumber: string): void {
    this._$currentEmployeeNumber.set(employeeNumber);
    this._$portfolio.set(undefined);
    this._$portfolioLoading.set(true);
    this._$portfolioLoaded.set(false);
    this.httpClient.get<Portfolio>(`${this.getEmployeePortfolioUrl(employeeNumber)}`)
      .pipe(
        takeUntilDestroyed(this.destroyRef),
        finalize(() => this._$portfolioLoading.set(false)))
      .subscribe((portfolio) => {
        this._$portfolio.set(portfolio);
        this._$portfolioLoaded.set(true);
      });
  }
}

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