Vivek Kumar Biswal’s Post

Most Angular developers misunderstand Angular Signals. They think: “𝗦𝗶𝗴𝗻𝗮𝗹𝘀 = 𝘀𝗮𝗺𝗲 𝗮𝘀 𝗢𝗻𝗣𝘂𝘀𝗵 𝗰𝗵𝗮𝗻𝗴𝗲 𝗱𝗲𝘁𝗲𝗰𝘁𝗶𝗼𝗻.” That’s completely wrong. Let’s break it down  • 𝗢𝗻𝗣𝘂𝘀𝗵 (𝗰𝗼𝗮𝗿𝘀𝗲-𝗴𝗿𝗮𝗶𝗻𝗲𝗱) With OnPush, Angular skips change detection unless:  • @𝗜𝗻𝗽𝘂𝘁 reference changes  • Event occurs(click event)  • Observable emits (async pipe) But when it runs…  • the 𝗲𝗻𝘁𝗶𝗿𝗲 𝗰𝗼𝗺𝗽𝗼𝗻𝗲𝗻𝘁 𝘁𝗲𝗺𝗽𝗹𝗮𝘁𝗲 𝗶𝘀 𝗰𝗵𝗲𝗰𝗸𝗲𝗱. Even if only ONE value changed.  • 𝗦𝗶𝗴𝗻𝗮𝗹𝘀 (𝗳𝗶𝗻𝗲-𝗴𝗿𝗮𝗶𝗻𝗲𝗱) Signals work differently. Angular tracks:  • 𝗲𝘅𝗮𝗰𝘁𝗹𝘆 𝘄𝗵𝗶𝗰𝗵 𝗽𝗮𝗿𝘁 𝗼𝗳 𝘁𝗵𝗲 𝘁𝗲𝗺𝗽𝗹𝗮𝘁𝗲 𝗿𝗲𝗮𝗱𝘀 𝘄𝗵𝗶𝗰𝗵 𝘀𝗶𝗴𝗻𝗮𝗹 So when a signal updates:  • 𝗢𝗡𝗟𝗬 𝘁𝗵𝗮𝘁 𝘀𝗽𝗲𝗰𝗶𝗳𝗶𝗰 𝗯𝗶𝗻𝗱𝗶𝗻𝗴 𝗶𝘀 𝗿𝗲-𝗲𝘃𝗮𝗹𝘂𝗮𝘁𝗲𝗱 Not the whole component. 𝗪𝗶𝘁𝗵 𝗢𝗻𝗣𝘂𝘀𝗵: > “Should I run change detection for this component?” 𝗪𝗶𝘁𝗵 𝗦𝗶𝗴𝗻𝗮𝗹𝘀: > “Which exact binding depends on this value?” In large apps: * OnPush still does unnecessary work * Signals minimize re-computation 𝘛𝘩𝘪𝘴 𝘪𝘴 𝘵𝘩𝘦 𝘳𝘦𝘢𝘭 𝘱𝘦𝘳𝘧𝘰𝘳𝘮𝘢𝘯𝘤𝘦 𝘸𝘪𝘯. Signals are not just a feature… They are a 𝗱𝗶𝗳𝗳𝗲𝗿𝗲𝗻𝘁 𝗿𝗲𝗮𝗰𝘁𝗶𝘃𝗶𝘁𝘆 𝗺𝗼𝗱𝗲𝗹. If you're still treating signals like variables inside OnPush, You're missing their real power. #Angular #Frontend #WebDevelopment #JavaScript #TypeScript #AngularDeveloper #DevCommunity #LearningInPublic #Programming

What exactly signal does for track the change ?

Like
Reply

To view or add a comment, sign in

Explore content categories