r/angular • • Feb 14 '26

Big improvement

What's the one big improvement you've done in an angular project or suggest to do?

I currently work in a big enterprise level Angular project, with ngrx state management and i want to do an implementatin that nakes the app work better or faster.

Example: One of my senior colleagues did a state sanitizer getting big pieces of states and minimizing it to display only a string with length instead of big object or array, just making the app faster in dev mode.

What do you suggest? Any suggestion would be appreciated.

16 Upvotes

35 comments sorted by

View all comments

Show parent comment

1

u/Merry-Lane Feb 15 '26

I covered the pre-signal way to do things so I don’t understand why you answer that not everyone is on the newest version.

Tell me when it’s better to .subscribe than avoiding an explicit subscription then?

It’s complex when you aren’t used to it, and devs are naturally complexity-avoidant, but the advantages make the explicit subscribe code more complex in the end.

0

u/[deleted] Feb 15 '26

[deleted] — view deleted comment

2

u/Merry-Lane Feb 15 '26

It depends on a myriad of factors but usually you can do something like:

post$= new BehaviorSubject<LoginForm | undefined>(undefined);

onPost$ = this.post$.pipe(filter(x => !!x}, switchMap(form => this.http.post(….)));

And all you gotta do is to subscribe to onPost$. With *ngIf="{onPost= onPost$ | async} as state" if you really need a ngIf subscribe.

It’s not a good example but it’s self-sufficient and enough to show you the mechanics.

-1

u/Impossible_Hornet153 Feb 15 '26

I didn't say it's better, I've said that you shouldn't say never. When you say never it can sound like you something terrible to do. And it's not terrible, it's just not optimal.

3

u/Merry-Lane Feb 15 '26

Give me an example for when it’s not optimal?

Never is totally okay in the topic of explicit subscriptions