{"id":931,"date":"2023-05-10T05:00:00","date_gmt":"2023-05-10T12:00:00","guid":{"rendered":"https:\/\/www.angulartraining.com\/daily-newsletter\/?p=931"},"modified":"2023-05-09T14:53:29","modified_gmt":"2023-05-09T21:53:29","slug":"signals-why-and-when-do-we-need-them","status":"publish","type":"post","link":"https:\/\/www.angulartraining.com\/daily-newsletter\/signals-why-and-when-do-we-need-them\/","title":{"rendered":"Signals: Why and when do we need them?"},"content":{"rendered":"\n<p>With the <a href=\"https:\/\/www.angulartraining.com\/daily-newsletter\/angular-16-is-now-available\/\" target=\"_blank\" rel=\"noopener\" title=\"\">release of Angular 16<\/a>, Signals are now available as a developer preview, which means we can start learning about <a href=\"https:\/\/www.angulartraining.com\/daily-newsletter\/angular-signals-are-in-the-works\/\" target=\"_blank\" rel=\"noopener\" title=\"\">Signals<\/a>, testing them, and possibly adopting them.<\/p>\n\n\n\n<p>The end goal of Signals is simple: <strong>Improve <a href=\"https:\/\/www.angulartraining.com\/daily-newsletter\/change-detection-for-angular-components\/\" target=\"_blank\" rel=\"noopener\" title=\"\">change detection<\/a> in the Angular framework<\/strong> by removing the need for Zone.js. A signal-based application will be able to update individual views (a view is a sub-set of a component template \u2014 we create new views every time we use structural directives such as <code>ngIf<\/code> or <code>ngFor<\/code>) one by one instead of checking the entire component tree, enabling <strong>laser-focused updates of our DOM<\/strong>.<\/p>\n\n\n\n<p>A secondary goal is to <strong>make Angular easier to learn<\/strong> by making RxJs less critical than before, which also applies to state management libraries such as NgRx or NgXs. In other words, we can rely less on operators, <a href=\"https:\/\/www.angulartraining.com\/daily-newsletter\/rxjs-subjects-when-and-why\/\" target=\"_blank\" rel=\"noopener\" title=\"\">subjects<\/a>, and the like.<\/p>\n\n\n\n<p>Now that we covered the <strong>why<\/strong>, let&#8217;s talk about <strong>when to use signals<\/strong>. To get the full benefit of Signals in the long run, using them everywhere we have Observables or data bindings makes sense. I know this sounds like a lot of work, but that&#8217;s how we can get to a point where Angular can tell <strong>exactly which components must be updated when a value changes<\/strong>, no matter their location in the DOM tree.<\/p>\n\n\n\n<p>An upcoming feature of Angular (v17 or later) will be <a href=\"https:\/\/github.com\/angular\/angular\/discussions\/49682\" target=\"_blank\" rel=\"noopener\" title=\"\">signal-based components<\/a>, where inputs, outputs, and even two-way bindings will be expressed as Signals:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"505\" height=\"257\" src=\"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-content\/uploads\/2023\/05\/image-11.png\" alt=\"\" class=\"wp-image-935\" srcset=\"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-content\/uploads\/2023\/05\/image-11.png 505w, https:\/\/www.angulartraining.com\/daily-newsletter\/wp-content\/uploads\/2023\/05\/image-11-300x153.png 300w\" sizes=\"auto, (max-width: 505px) 100vw, 505px\" \/><\/figure>\n<\/div>\n\n\n<p><\/p>\n\n\n\n<p>I believe it makes sense to start using Signals as soon as possible. The base API is available in Angular 16 and is easy to learn. I already published a <a href=\"https:\/\/angular-training.getlearnworlds.com\/course\/angular-signals\" target=\"_blank\" rel=\"noopener\" title=\"\">course that will be continuously updated as Signals evolve<\/a>.<\/p>\n\n\n\n<p>If you have any specific questions or concerns, feel free to send me your questions. I&#8217;ll be covering more about Signals as part of this newsletter.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>With the release of Angular 16, Signals are now available as a developer preview, which means we can start learning about Signals, testing them, and possibly adopting them. The end goal of Signals is simple: Improve change detection in the Angular framework by removing the need for Zone.js. A signal-based application will be able to [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,29],"tags":[],"class_list":["post-931","post","type-post","status-publish","format-standard","hentry","category-angular","category-signals"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-json\/wp\/v2\/posts\/931","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-json\/wp\/v2\/comments?post=931"}],"version-history":[{"count":4,"href":"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-json\/wp\/v2\/posts\/931\/revisions"}],"predecessor-version":[{"id":936,"href":"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-json\/wp\/v2\/posts\/931\/revisions\/936"}],"wp:attachment":[{"href":"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-json\/wp\/v2\/media?parent=931"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-json\/wp\/v2\/categories?post=931"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-json\/wp\/v2\/tags?post=931"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}