NateDevelops

461 posts

NateDevelops banner
NateDevelops

NateDevelops

@NateDevelops

Let's develop together 💻 Angular | TypeScript | RxJS 🧠 ESTJ | 1w9 | Editor (Cs)

Katılım Mart 2020
144 Takip Edilen86 Takipçiler
Sabitlenmiş Tweet
NateDevelops
NateDevelops@NateDevelops·
🚀 Modern Angular Baseline Tips Posted this to my team - do you agree/disagree? Anything I missed? "Lots of new tech is stable and lots of old tech is becoming deprecated so it's a good time to take stock! At this point I would go as far to say that not following any of these tips is effectively baking tech debt into the platform based on where Angular is and is intending to go. Would love to hear your thoughts though. If we're aligned, we can factor them into code review etc going forward. Control Flow/Queries • No need to use *ngIf/*ngFor/*ngSwitch anymore  → Use ﹫if/﹫for/﹫switch instead (we all know this one) • No need to use ﹫Input/﹫Output()/﹫ViewChild[ren]/﹫ContentChild[ren] anymore  → Use input()/output()/viewChild[ren]()/contentChild[ren]() instead Styles • No need to use ngClass or ngStyle anymore  → Use [class] and [style] instead. These are functionally equivalent and avoid the NgClass and NgStyle imports Modules/Imports • No need to import CommonModule anymore  → Just import the specific classes you need. In practice this tends to be things like NgTemplateOutlet or common pipes like DatePipe or JsonPipe. NgIf/NgFor/NgSwitch/NgClass/NgStyle were the reason that CommonModule used to be a standard import in components, but all of them are now deprecated • No need to use NgModules anymore. They should not be created for new components  → Components should now import what they need directly  → Module-level imports (which are rarely needed now) should be placed in the root feature component  → Module-level providers should be placed in either the root feature component or the route corresponding with that feature • No need to manually create destroy$ subjects  → Inject destroyRef and use takeUntilDestroyed(this.destroyRef) instead of takeUntil(this.destroy$) State • All new state variables should be being built with signals: signal()/computed()/linkedSignal(). • Services/repositories/general HTTP usage can still be RxJS heavy but by the time state is consumed by component templates they should be signals.  Implied here is that the AsyncPipe should no longer be used. • Signals are a declarative paradigm so we should be looking to minimise imperative code as much as possible, but sometimes it’s inevitable (e.g. updating a Reactive form pre-v21).  In this case we should use effect() to watch signals for changes or .subscribe() to watch observables for changes.  Inherently imperative events like click-handlers will continue to need imperative solutions. • To facilitate all of the above we should be looking to migrate core pieces of application state to signals when possible. As an example, I recently migrated currentUser to a signal from a BehaviourSubject. This now means any component in the application can reactively consume currentUser without any RxJS/subscriptions. Lifecycle hooks • Once all inputs in a component are migrated to input(), ngOnChanges is no longer necessary • Once all queries in a component are migrated to viewChild[ren]()/contentChild[ren](), ngAfterViewInit is no longer necessary • Once a component is using destroyRef, manual unsubscription is not needed so ngOnDestroy is not needed in a large number of cases • If a component’s state can be modelled fully in signals, ngOnInit is also not necessary In summary, in a fully modern Angular component, you should expect to encounter ngOnInit and rarely ngOnDestroy but never ngOnChanges/ngAfterViewInit. There are more but I think this is a pretty solid list that impacts our day to day."
English
2
3
61
4.9K
NateDevelops retweetledi
Del Chick
Del Chick@call_me_dc_·
@angular Angular is a framework of "when," not just "what." Don’t just write code; understand when Angular decides to run it. If you master the lifecycle hooks, you’ll stop fighting the framework and start dancing with it.
English
2
0
6
356
Angular
Angular@angular·
Think back to when you started 🐣 What is the one piece of advice you’d give to a developer just starting their Angular journey today? Share your wisdom and help a newcomer grow.
English
20
4
48
8.1K
NateDevelops
NateDevelops@NateDevelops·
@bjeaurn @angular Love this! Also "explicit types are unit tests for your variables" is a line that redefined the way I looked at types. Yes it's verbose to type out what can be inferred just as it's verbose to type out unit tests but both have their place! Give the control to the developer
English
0
0
1
18
🦋 Bjorn 'Bjeaurn'
🦋 Bjorn 'Bjeaurn'@bjeaurn·
@angular Maybe a completely different take; Types are your friend. Don’t lie to the compiler. Learn to embrace that defining the shapes of your objects helps prevent bugs and makes your code that much more readable.
English
1
0
4
92
NateDevelops
NateDevelops@NateDevelops·
I haven't found an auto-formatter that is sufficiently configurable, so I just use organise imports/auto semi-colons and format the rest by hand 😅 AI picks up the formatting of the project so it doesn't cause me too much grief! I have started the "Let's all use Prettier!" thing at 3 different companies and always backed out when we realised what we couldn't change
English
0
0
1
14
IP
IP@ipwanciu·
I was too excited not to try it! Now the code element has formatting with @PrettierCode. tbh, it was easier than I thought! Alongside this small feature, other small features were done, like opacity (not hidden) edges behind the workspace edges, sticky lines, and improved grids. Many new small features are coming as well! Thanks, @sercan, for the formatting idea. 🔥
Sercan@sercan

@ipwanciu Looking good! It would be nice if you can add formatting support with Prettier. I always find myself changing before sharing for privacy and such and end up messing up the formatting.

English
2
1
5
946
NateDevelops
NateDevelops@NateDevelops·
I haven't found an auto-formatter that is sufficiently configurable, so I just use organise imports/auto semi-colons and format the rest by hand 😅 AI picks up the formatting of the project so it doesn't cause me too much grief! I have started the "Let's all use Prettier!" thing at 3 different companies and always backed out when we realised what we couldn't change
English
0
0
0
8
NateDevelops
NateDevelops@NateDevelops·
Declarative programming = easier to reason about code = less bugs on new features/refactors Signals = reactive primitives = state dependency chains = more efficient/relevant change detection = performance gains
English
0
0
1
90
Anshul Jain
Anshul Jain@itsaj123·
@angular As of now I'm in a phase where i am convincing my clients to migrate from angular 16 to 20, but they are having the same thoughts , If the app is working then let it work. Any good suggestions to convince them?
English
2
0
1
553
Angular
Angular@angular·
Signals continue to transform how we handle reactivity. 🚦 If you’re currently migrating an older project to Signals, what has been your biggest "aha!" moment so far? Tell us about your migration journey below.
English
10
6
68
11.5K
NateDevelops
NateDevelops@NateDevelops·
@MichaelSmallDev No way! My original comment was actually inspired by injectQueryParams which has the same limitations haha Incredible news, thanks for sharing ❤️
English
0
0
1
20
NateDevelops
NateDevelops@NateDevelops·
I just want a signal of URL params/queryParams/fragments that isn't tied to the component tree 😭 I assume this still isn't possible? I was hoping we could statically analyze the route configs and still keep the variable names without needing to be within a component to access them?
English
1
0
1
30
NateDevelops
NateDevelops@NateDevelops·
Present tense seems more generalisable to me. It conveys that the emission is an event not a state. To test that idea, hold up the name against an inbuilt EventEmitter (click). Would (clicked) make sense, probably, but I think (click) is nicer because it is stateless Of course you can consume state from outputs, but I would say they are more akin to observables (event is the primary use case, state is secondary) vs signals (state is primary, event is secondary)
English
1
0
1
25
Gerome Grignon 🅰️ @AngularDevsFr
How do you name your @angular outputs? I keep working on an upcoming Angular agent skills collection, including best practices. Past tense = "something happened" (event notification) Present tense = "do this specific thing" (action delegation)
Gerome Grignon 🅰️ @AngularDevsFr tweet media
English
3
0
4
250
NateDevelops retweetledi
Angular
Angular@angular·
We’re planning to make OnPush the new default Change Detection Strategy in v22. Also, ChangeDetectionStrategy.Default would be renamed to Eager. Check out the RFC and let us know what you think: github.com/angular/angula…
English
11
35
275
14.8K
NateDevelops
NateDevelops@NateDevelops·
Bought my @angularbelgrade ticket - May 7th, super cheap if you buy before Jan 31st! Anyone else going/thinking of going?
English
1
1
3
96
NateDevelops
NateDevelops@NateDevelops·
@Armandotrue Let's hope we're rich by then and I'll come join you in your yacht and we can talk about the good ol' days 😂
English
1
0
1
15
Armen Vardanyan
Armen Vardanyan@Armandotrue·
@NateDevelops Ideally LLMs write the website and then finally other LLM-powered bots consume the website lmao 🤣
English
1
0
1
20
Armen Vardanyan
Armen Vardanyan@Armandotrue·
Many discussions around LLM coding tools go like this: - coding tools are garbage, they never solve the problem for me, it's just hype! - you're using it wrong, I defined constraints, invoked other tools for review, made it work step by step, explained the architecture, provided the right context and it did a stellar job! Maybe there is a lesson there 🤔
Armen Vardanyan tweet media
English
1
1
5
694
NateDevelops
NateDevelops@NateDevelops·
True! But I guess the aspect I find interesting is that who judges whether an LLMs output is good? It's the human on the other side. It's a subjective, individual assessment. The same output can be good or bad to different people. That's why I think the smaller the chunk and the bigger the direction by the human user the more likely the user will subjectively evaluate the output as "good" (as it's just closer to what they had in mind, not that it's better in an objective sense) We all know LLMs can one-shot a website but if they can why don't those v1s ever make it to production? It might be good enough for a handful of people but usually the human wants control over the smaller details. Food for thought! You're right though, I probably trivialised the AI thinking element still being amazing, thanks for pointing that out 😁
English
1
0
1
18
Armen Vardanyan
Armen Vardanyan@Armandotrue·
I guess it is not as sharp of a distinction as you say, but I get the idea. Coding agents (well LLMs under them) can "think", and sometimes better than humans. But yet again, mistakes are unavoidable. It's not an "AI thing", it's an "everything thing", any system can fail, and the more complex it or the task at hand is, the more probable a mistake becomes, and then you need it to go back. Will we able to just prompt ourselves out of any situation? Well, maybe, but not right now. And if not, could we fix it without the underlying knowledge?
English
1
0
1
65
NateDevelops
NateDevelops@NateDevelops·
@marktechson * cues montage of Mark dusting off his black t-shirt and gold chain *
GIF
English
1
0
1
42
Mark Techson
Mark Techson@marktechson·
Today is my last day on Christmas vacation. I took extra time off to be with my family, rest, and re-center. I'm going back to work on Monday, supercharged and ready to go bigger than I ever have. We are on one.
English
5
0
29
919
NateDevelops
NateDevelops@NateDevelops·
@itsaj123 @Armandotrue I have tried this but in practice I don't enjoy it as much because change detection becomes a pain (force-updating the object's reference vs primitive changes just automatically being detected). Just personal taste though! It looks neater for sure
English
1
0
2
25
Anshul Jain
Anshul Jain@itsaj123·
@Armandotrue I agree, a better approach can be to have one input of type object
English
2
0
2
619
Armen Vardanyan
Armen Vardanyan@Armandotrue·
I think some might disagree, but a component with too many inputs is just a code smell to me
Armen Vardanyan tweet media
English
19
5
68
7.9K
NateDevelops
NateDevelops@NateDevelops·
@Jean__Meche @renatoaraujoc Can't believe I didn't know this AND I just built something that relied on this behaviour that I now have to rework..😂 sad times. A welcome change!
English
0
0
1
26