𝗜 𝘀𝗽𝗲𝗻𝘁 𝟰 𝗵𝗼𝘂𝗿𝘀 𝗱𝗲𝗯𝘂𝗴𝗴𝗶𝗻𝗴 𝗮 "𝗴𝗵𝗼𝘀𝘁 𝗨𝗜" — 𝗰𝗼𝗺𝗽𝗼𝗻𝗲𝗻𝘁𝘀 𝘁𝗵𝗮𝘁 𝗿𝗲𝗳𝘂𝘀𝗲𝗱 𝘁𝗼 𝘂𝗽𝗱𝗮𝘁𝗲 𝗼𝗻𝗹𝘆 𝘁𝗼 𝗿𝗲𝗮𝗹𝗶𝘀𝗲 𝗜 𝗰𝗮𝘂𝘀𝗲𝗱 𝗶𝘁 𝗺𝘆𝘀𝗲𝗹𝗳. 1. We had a real-time dashboard in Angular showing live sensor data. Product was happy. QA was happy. Then staging broke. 2. 𝗥𝗼𝘄𝘀 𝘄𝗲𝗿𝗲𝗻'𝘁 𝗿𝗲-𝗿𝗲𝗻𝗱𝗲𝗿𝗶𝗻𝗴 𝗮𝗳𝘁𝗲𝗿 𝗱𝗮𝘁𝗮 𝘂𝗽𝗱𝗮𝘁𝗲𝘀. The array was clearly mutating in the console. The template just… didn't care. 3. I'd switched the component to ChangeDetectionStrategy.OnPush for "performance" — without understanding what that actually means. 𝗧𝗵𝗲 𝗺𝗶𝘀𝘁𝗮𝗸𝗲: ❌ Mutating the array directly — OnPush never sees this this.sensors.push(newSensor); this.sensors[0].value = 99; With OnPush, Angular only checks a component when its input reference changes — not when you mutate the object inside it. 𝗧𝗵𝗲 𝗳𝗶𝘅: ✅ Return a new reference — Angular picks it up instantly this.sensors = [...this.sensors, newSensor]; this.sensors = this.sensors.map((s, i) => i === 0 ? { ...s, value: 99 } : s ); Or — if you're already using signals in Angular 17+ — just use a signal() and skip this mental overhead entirely. 𝗧𝗵𝗲 𝗿𝗲𝗮𝗹 𝗹𝗲𝘀𝘀𝗼𝗻: OnPush is not a magic performance button. It's a contract you promise Angular you'll treat state as immutable. Break the contract, pay in ghost UIs. 𝗔𝗱𝗼𝗽𝘁 𝗶𝘁. 𝗟𝗼𝘃𝗲 𝗶𝘁. 𝗕𝘂𝘁 𝘂𝗻𝗱𝗲𝗿𝘀𝘁𝗮𝗻𝗱 𝗶𝘁 𝗳𝗶𝗿𝘀𝘁. 𝗠𝘆 𝗾𝘂𝗲𝘀𝘁𝗶𝗼𝗻 𝘁𝗼 𝘆𝗼𝘂 → Have you ever turned on OnPush and immediately broken something? What was your "wait, THAT was the issue?" moment? Drop it below. 👇 #Angular #TypeScript #WebDevelopment #FrontendDevelopment #SoftwareEngineering #LearnInPublic #CodingMistakes
Angular OnPush Gotcha: Immutable State and Real-Time Data
More Relevant Posts
-
Is your Angular Dependency Injection working for you, or against you? DI is often treated as just a "way to get services into components." But in a large-scale Angular application, it is the backbone of your entire architecture. If you get DI wrong, you end up with tightly coupled code that is a nightmare to test and impossible to refactor. If you get it right, your app becomes modular, lean, and truly performant. In my latest post on the Pistackio blog, I dive deep into: ✅ Why the inject() function is a game-changer for modern Angular. ✅ Decoupling logic for cleaner, more maintainable systems. ✅ Common DI pitfalls that kill your Lighthouse scores. Stop fighting the framework and start leveraging its greatest strength. Read the full deep dive here: https://lnkd.in/dxSCHmaE
To view or add a comment, sign in
-
Ever spent hours debugging something that shouldn’t even be a problem? I did recently. We had a simple Angular screen. API was working fine. Data was coming correctly. No errors in console. Still… the UI refused to update. At first glance, everything looked normal: • API call successful • Data assigned to component variable • Template binding correct But the UI stayed stuck with old data. After digging deeper, the issue turned out to be Change Detection. The data was being updated inside a callback that Angular wasn’t tracking (a third-party library hook). So Angular never knew it had to re-render. The fix? Instead of forcing hacks everywhere, I handled it properly: • Injected ChangeDetectorRef • Used detectChanges() at the right place • Later refactored to bring logic back inside Angular zone using NgZone What I learned (again): Clean code isn’t enough. Understanding how Angular thinks is what actually saves you. Sometimes the bug isn’t in your logic — it’s in the framework lifecycle. #Angular #Frontend #Debugging #WebDevelopment #SoftwareEngineering
To view or add a comment, sign in
-
I just updated my 𝗘𝘀𝘀𝗲𝗻𝘁𝗶𝗮𝗹 𝗔𝗻𝗴𝘂𝗹𝗮𝗿 𝗦𝗶𝗴𝗻𝗮𝗹𝘀 𝗖𝗵𝗲𝗮𝘁𝘀𝗵𝗲𝗲𝘁 for 𝗔𝗻𝗴𝘂𝗹𝗮𝗿 𝟮𝟮. The signals ecosystem keeps growing and I wanted to make sure the cheatsheet reflects where things are today — from v16 all the way to v22. 𝗪𝗵𝗮𝘁'𝘀 𝗻𝗲𝘄: → 𝚍𝚎𝚋𝚘𝚞𝚗𝚌𝚎𝚍() is now included — Angular's first signal-native debouncing primitive. You give it a signal and a wait time, it gives you back a full 𝚁𝚎𝚜𝚘𝚞𝚛𝚌𝚎‹𝚃› with value, status, loading state, and error handling. No RxJS needed. Link to the full article (if you perfer medium check comments) 👇 https://lnkd.in/dezZdvCy ♻️ Repost if this is useful for your team. #angular #signals
To view or add a comment, sign in
-
Day 23 of 30: Data Binding in Blazor. Today I covered Data Binding, how your UI and your C# data stay connected automatically. In most frameworks you manually update the UI when data changes. In Blazor, binding does that for you. You connect a variable to an HTML element and whenever that variable changes, the UI updates. No extra code, no manual DOM manipulation, it just works. There are two types of binding in Blazor. One-way binding displays data from your C# variable in the UI using @variableName. The UI shows the value but can't change it. Two-way binding uses @bind-Value and works in both directions. When the variable changes the UI updates, and when the user types something in the UI the variable updates too. One line of code replaces what would take multiple event listeners in JavaScript. One thing that clicked today, two-way binding is what makes forms feel alive. You bind an input field to a C# property, and as the user types, your property updates in real time. No button click needed to collect the value, no manual reading from the DOM. By the time the user hits submit, your C# object already has everything filled in and ready to send. Day 24 tomorrow; Event Handling. Making your Blazor UI actually respond to what the user does. #Blazor #dotNET #DataBinding #BuildingInPublic #30DayChallenge #dotNETCore
To view or add a comment, sign in
-
-
Popular Article: From Template-Driven to Signal-Driven: The Complete Evolution of Angular Forms, By Sonu Kapoor This article by Sonu Kapoor delves into the evolution of Angular forms from template-driven to signal-driven. He explains the benefits and challenges of each approach and demonstrates how to implement signal-driven forms in an Angular application. Read the full article published in CODE Magazine here: bit.ly/40mJ2k5
To view or add a comment, sign in
-
Every Angular project has a table. This dev got tired of rewiring MatSort, MatPaginator, and SelectionModel from scratch each time and built a library for it. Column config, signals API, styled Excel export, drag reorder and the SheetJS trap to avoid. { author: Zonaib Bokhari } https://lnkd.in/edCzK4g7
To view or add a comment, sign in
-
I just published a deep dive on one of Angular's most misunderstood topics. 🔥 Angular Change Detection: The Thing Nobody Explains Properly (Until Now) If you've ever: → Wondered why your UI wasn't updating → Seen ExpressionChangedAfterItHasBeenCheckedError and panicked → Sprinkled detectChanges() everywhere hoping for the best → Heard "use OnPush" but never understood why ...this one's for you. What the article covers: ✅ How Zone.js silently triggers change detection (and why that's a problem) ✅ CheckAlways vs OnPush — with real code examples ✅ The 5 most common CD mistakes and exactly how to fix them ✅ Angular Signals and the zoneless future ✅ Performance patterns that actually move the needle
To view or add a comment, sign in
-
I just published a new article on Angular architecture: Declarative vs. Imperative: Which is Better in Angular? Most developers think manual subscriptions are "just how Angular works", but in reality, apps become a buggy mess of memory leaks and race conditions because of that exact mindset. https://lnkd.in/ehpXdJ6K
To view or add a comment, sign in
-
🚀 Real-World Angular Mistakes – Series 🚀 Day 3 – Smart vs Dumb Components (Wrong Usage) Most developers know: 👉 Smart components 👉 Dumb components 🔥 But here’s the problem 👉 They use them incorrectly 🔴 The Real Mistake In real projects: ❌ Business logic inside UI components ❌ API calls inside dumb components ❌ Reusable components tightly coupled 👉 Result? ❌ Hard-to-reuse components ❌ Poor separation of concerns ❌ Difficult testing 🔹 Wrong Approach @Component({...}) export class UserCardComponent { user: any; ngOnInit() { this.userService.getUser().subscribe(data => { this.user = data; }); } } 👉 UI component doing API calls ❌ 🟢 Correct Approach Smart Component (Container) @Component({...}) export class UserContainerComponent { user$ = this.userService.getUser(); } Dumb Component (Presentational) @Component({...}) export class UserCardComponent { @Input() user: any; } 🧠 Enterprise Insight 👉 Smart components = logic 👉 Dumb components = UI 🎯 Simple Rule ✔ Fetch data in containers ✔ Pass data via @Input ✔ Keep UI components reusable ⚠️ Common Mistake 👉 “Small component, so it’s fine” 👉 NO ❌ 👉 This breaks scalability 🔥 Gold Line 👉 “If your UI component knows APIs, it’s no longer dumb.” 💬 Do you strictly follow smart/dumb separation? 🚀 Follow for Day 4 – Ignoring Change Detection Strategy (Performance Killer) #Angular #FrontendArchitecture #Performance #CleanCode #UIDevelopment
To view or add a comment, sign in
-
-
How are you calculating averages in Angular templates today? {{ reviews | average:'rating' }} One pipe. No component logic. No computed properties. Works with primitives and object arrays: {{ [85, 92, 67, 94, 71] | average }} → 81.8 {{ students | average:'grade' }} → class average {{ data | average:'metrics.score' }} → nested paths too npm i ngx-transforms https://lnkd.in/dRYZts_V #Angular #TypeScript #WebDev #ngxTransforms
To view or add a comment, sign in
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development
Aashish Bhagwat is a Senior Software Engineer and Certified Angular Developer, specializing in building AI-powered web applications for startups. With a strong command of technologies including Node.js, React.js, and Laravel, Aashish delivers robust and innovative solutions. As an N8N expert, Aashish also streamlines automation workflows, enhancing operational efficiency and driving growth for emerging ventures.