<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Preston Lamb on Medium]]></title>
        <description><![CDATA[Stories by Preston Lamb on Medium]]></description>
        <link>https://medium.com/@pjlamb12?source=rss-39b42ea5b9d4------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*SCFGhmBnoCApLScPm-Kw0w.jpeg</url>
            <title>Stories by Preston Lamb on Medium</title>
            <link>https://medium.com/@pjlamb12?source=rss-39b42ea5b9d4------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 23:36:40 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@pjlamb12/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[My Favorite AI Tools for Building Angular Apps]]></title>
            <link>https://medium.com/ngconf/my-favorite-ai-tools-for-building-angular-apps-1c367d83f0af?source=rss-39b42ea5b9d4------2</link>
            <guid isPermaLink="false">https://medium.com/p/1c367d83f0af</guid>
            <category><![CDATA[claude-code]]></category>
            <category><![CDATA[gemini]]></category>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[google-antigravity]]></category>
            <category><![CDATA[ai]]></category>
            <dc:creator><![CDATA[Preston Lamb]]></dc:creator>
            <pubDate>Thu, 07 May 2026 14:21:01 GMT</pubDate>
            <atom:updated>2026-05-07T14:21:01.205Z</atom:updated>
            <content:encoded><![CDATA[<h3>tldr;</h3><p>It’s incredible how fast AI has become part of our daily lives, both inside and outside our work as developers. I have been a pretty quick adopter of AI tools, and in many ways it’s allowed me to learn more about different topics, solve problems I was facing for work, and build applications for personal as well as professional use that I just didn’t have time to build before. What I’ve found, however, is that a well-curated set of tools is essential. It’s not just about using AI; it’s about understanding the specific role each tool plays in your workflow to ensure you actually cross the finish line. In this article, I’ll share my process of how I’ve built several Angular and full stack applications so far this year using AI tools, and the specific tools that I use to accomplish different tasks.</p><blockquote><em>For this article, I will use a library app as the demo project, one that keeps track of books that you own, have read, etc. It’s not one I’ve built, so I’ll use it as an example of the process I go through to build a new application.</em></blockquote><h3>First Step: A Good Plan</h3><p>Every good project starts with a well-defined plan, clear goals, and desired outcomes. This is obviously not unique to software development; it applies to every project we want to take on in our lives. Thus, I’ve found that just jumping into Antigravity or Claude and saying something along the lines of “build me an app that manages my library of books” will not get you very far. Or at least, it won’t get you very far with a usable result. Sometimes the AI model will prompt you for some more information, but it also may just start to build something for you before getting all the details it needs. To prevent this from happening, I like to develop a good plan and project outline before anything starts.</p><p>To make this plan, I still will start with an AI model. I generally use Gemini for things like this, but any of the offerings out there should work. My initial prompt will be something like this:</p><blockquote><em>I want to build an application that will allow me to manage my library of books. I want to be able to add books, edit them, and delete them. I should be able to rate them after reading them, tag them for organization, and other library-type actions. For the stack, I want an Nx workspace with a Nest API and an Angular frontend. I want to use PrimeNg for the component library and Tailwind for styling. Make sure to use modern Angular patterns, including control flow syntax and Signals. Ask me questions so we can build out a good plan for this project.</em></blockquote><p>This prompt gives the AI model a good starting point. It’s not making any decisions yet, and it’s not guessing at what I want. From here, it can ask some follow up questions to make sure we include all the features that I want (i.e. “Would you like to keep track of loaning your books to friends?” or “Do you want to keep track of the format of the book?”). Many times, the model will help me think of features that I didn’t think of, or it asks about something that I know I do not want to include. All of this gives the model a clear understanding of what I want to build. Even for a big project, the scope will be much more well defined after this process.</p><p>I will continue with this process until I feel like I have all the features I want included, and all the details ironed out. I will then ask the model to give me a technical requirements document based on the project we’ve designed. I’ll take the output and save it as a markdown file on my computer. This document will serve as the reference point for the beginning of my project. Sometimes the project begins to veer off course, and I can get back on track by referring back to the TRD. Other times I allow it to veer off because we have come up with a better plan.</p><h3>Second Step: The Right Tools</h3><p>After generating the TRD, I’m ready to get started on building the project. You can do some of this on your own, or you can turn it all over to an AI model. However, you need to have a good tool in place for any amount of AI involvement. I primarily use three different tools for this step: Antigravity, Gemini CLI, and Claude. Each of them has its strengths and weaknesses, but I have pretty successfully used them together to build applications. Antigravity is great if you like to work in an IDE, where you’re able to easily view the files that are being updated alongside a chat window with the agent. Gemini CLI and Claude are great if you are comfortable being in a terminal session and chatting with the agent while not paying as much attention to the file structure without opening the repo up in an IDE. Neither of these tools is “better” than the other, it merely depends on what you feel most comfortable with.</p><blockquote><em>I should point out, I have a Gemini Pro subscription due to a purchase of a phone last year, and I paid for a Claude Pro license as well. If you don’t have a subscription to a tool like this, your ability to use AI for development will be severely limited.</em></blockquote><p>Once you have your selected tool installed and ready to go, you are ready to start building. This is where a couple more tools come into play. I use two tools pretty frequently to help with the actual building of the app. The first is <a href="https://github.com/gsd-build/get-shit-done">GSD, or get-s***-done, by gsd-build</a>. It’s described as “a light-weight and powerful meta-prompting, context engineering and spec-driven development system”. Essentially, it will take a set of requirements you give it and generate a detailed plan broken down into milestones and phases. During each phase, you will be asked several questions where you can give your answers or select recommended options from the model. The depth and detail that GSD goes into has been surprisingly good in my experience, and is another way that I have made sure to not forget necessary features along the way.</p><p>Another tool that I recently started using but has helped with the UI/UX side of things is the <a href="https://github.com/nextlevelbuilder/ui-ux-pro-max-skill">UI/UX Pro Max skill from next-level-builder</a>. I’ve only used this a couple of times, but it has done a great job at setting up a reasonable style guide and normalizing the use of classes and other design tokens instead of the general HTML and CSS written by AI models. This is a new tool for me, but some coworkers of mine have been using it extensively and have been happy with the results.</p><p>Another tool that I was recently introduced to and comes highly recommended is called <a href="https://github.com/garrytan/gstack">gstack by Garry Tan</a>. The goal with gstack is to turn your AI model into a full team to help with planning a project. You get a CEO, designer, engineering manager, release engineer, and more all in one tool. Where GSD takes what you want and plans that out, without much push back or questioning your motivations, gstack is designed to put you through a real planning session: why are you building this, is there a market for it, etc. Like I said, I was just introduced to this tool, but it seems like it could be a great way to make sure you have a solid plan in place before you start building.</p><blockquote><em>As an example of gstack, my one time using it so far, I told it I wanted to expound on a POC project I’d started for work. I wanted to build out the project more in depth, and it pushed back asking if there was real buy in for the project, or if I’d be wasting my time on something that would never land. It was actually a great example of what the tool can do if you’re starting on a brand new project.</em></blockquote><h3>MCP Servers</h3><p>I don’t have a lot of specific MCP servers that I use, but look for ones that are designed for the tools you use. GitHub is a good one so it can create issues, close issues, push and pull, create PRs, etc. It’s really helpful to have everything tracked in GitHub. We use ClickUp at work for tracking tickets, so I use that MCP server as well. I’ve heard good things about the Sentry MCP server as well, but haven’t used it for my projects yet. Regardless, many tools that you are already using have MCP servers. Download and run them while you’re working on the project and I’m sure your project will be better off for it.</p><h3>Third Step: Building the App</h3><p>After all the prep work you’ve done up to this point, you’re ready to get started on the project. Because of that prep work you’ll be set up to make quick progress on the project. However, I still don’t recommend just letting the agent write code without any human intervention. For the most part, I do let it write all the code, and then as it stops to ask for reviews I’ll ensure I do that. If it wants me to review a given implementation in the code, I’ll do that. If it just needs a human to test the interaction in the application, I’ll do that as well. This is important because many times it thinks it’s implemented a feature correctly and I find that it has not. The longer you let it go without checking, the more work you will have in the future to get back on track.</p><p>I also like to run the linting, unit tests, and end-to-end tests frequently to ensure that we are not breaking things as we move forward. I’ll run them manually after each GSD phase, but I’ll also instruct the agent to run the tests as it goes along as well. This is one more way to ensure we have quality code that does what we expect it to do.</p><h3>Conclusion</h3><p>We live in a new world, one different than even just a couple years ago. The ability to increase our output with the use of AI agents is exciting. This year I’ve built multiple full stack applications and improved some open source libraries that I maintain using AI tools. If not for those tools, I wouldn’t have finished any of those projects. It’s easy to want to push back on using these tools, but I encourage everyone I talk to to embrace the change and to learn how to effectively use the tools in their day to day work. The more you use them, the more comfortable you will be and the more quality code you will be able to produce.</p><h3>Referenced Resources &amp; Tools</h3><h3>AI Development Platforms</h3><ul><li><a href="https://antigravity.google/"><strong>Antigravity</strong></a> — Google’s agent-first IDE (fork of VS Code) optimized for Gemini and autonomous coding tasks.</li><li><a href="https://claude.ai/"><strong>Claude</strong></a> — Anthropic’s LLM, highly effective for code generation and architectural reasoning.</li><li><a href="https://gemini.google.com/"><strong>Gemini</strong></a> — Google’s multimodal AI, excellent for initial planning and large-context window tasks.</li></ul><h3>Planning &amp; Workflow Skills</h3><ul><li><a href="https://github.com/gsd-build/get-shit-done"><strong>GSD (get-s***-done)</strong></a> — A spec-driven development system for breaking down projects into actionable milestones and phases.</li><li><a href="https://github.com/garrytan/gstack"><strong>gstack by Garry Tan</strong></a> — An open-source toolkit that adds “engineering team” personas (CEO, QA, etc.) to your AI workflow.</li><li><a href="https://github.com/nextlevelbuilder/ui-ux-pro-max-skill"><strong>UI/UX Pro Max Skill</strong></a> — An AI skill designed to provide high-level design intelligence and consistent styling tokens.</li></ul><h3>Model Context Protocol (MCP) Servers</h3><ul><li><a href="https://github.com/modelcontextprotocol/servers"><strong>GitHub MCP</strong></a> — Standard server for managing issues, PRs, and repository actions.</li><li><a href="https://developer.clickup.com/docs/connect-an-ai-assistant-to-clickups-mcp-server"><strong>ClickUp MCP</strong></a> — Integrate your workspace tasks and docs directly into your AI chat context.</li><li><a href="https://github.com/modelcontextprotocol/servers"><strong>Sentry MCP</strong></a> — Helpful for feeding error logs and performance issues directly to your AI agent for debugging.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1c367d83f0af" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ngconf/my-favorite-ai-tools-for-building-angular-apps-1c367d83f0af">My Favorite AI Tools for Building Angular Apps</a> was originally published in <a href="https://medium.com/ngconf">ngconf</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Modernize Your Components: The Power of Signal Inputs and Outputs]]></title>
            <link>https://medium.com/ngconf/modernize-your-components-the-power-of-signal-inputs-and-outputs-7d749dd5683a?source=rss-39b42ea5b9d4------2</link>
            <guid isPermaLink="false">https://medium.com/p/7d749dd5683a</guid>
            <category><![CDATA[angular-signals]]></category>
            <category><![CDATA[angular]]></category>
            <dc:creator><![CDATA[Preston Lamb]]></dc:creator>
            <pubDate>Wed, 10 Dec 2025 13:02:42 GMT</pubDate>
            <atom:updated>2025-12-10T13:02:42.018Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>Virtually every Angular application centers around displaying information to an end user, and that user interacting with the application in some way. Angular has always had a way to react to changes in the data or state of the application, but it’s been made more performant in recent years with the introduction of signals. Signals can be used in a lot of different situations in a component, but a great way to use them is in conjunction with inputs and outputs to components.</p><p>If you’ve used Angular before, you’ll be familiar with the <a href="http://twitter.com/Input">@Input</a> and <a href="http://twitter.com/Output">@Output</a> decorators for components. Using signal inputs and outputs is not just a change in syntax, but a change in the overall reactivity of the application. In this article, we’ll look at how to use these special types of signals and some of the benefits of using them.</p><h3>Input Signals</h3><p><strong>The Basics</strong></p><p>The <a href="http://twitter.com/Input">@Input</a> decorator is a frequently used feature of components and directives in Angular, allowing developers to pass data from parent components to children. However, traditional <a href="http://twitter.com/Input">@Input</a> properties rely on Angular’s standard change detection to verify if values have changed. In a default setup, this means your app could potentially check every single component during each change detection cycle to ensure the UI matches the state. This performance bottleneck is where signals really shine. Because signals are reactive, Angular knows exactly when a value has updated. Instead of traversing the entire component tree, the framework can update only the specific parts of the DOM that changed.</p><p>Signal inputs for components give you this performance benefit with an intuitive API and easy use case. There are, however, some differences between the two variants of inputs. Let’s explore signal inputs, and we’ll look at those similarities and differences.</p><pre>export class MyComponent {<br> @Input() name !: string;<br> firstName = input&lt;string&gt;();<br>}</pre><p>The example above shows both ways of declaring inputs to the component. One of the big differences you’ll notice is with the decorator, where we need to use the ! operator in the type declaration for the name variable. This is called the definite assignment assertion operator, and it notifies TypeScript that while there is no value currently assigned to the variable, you will ensure that a value is provided before attempting to use it. This operator is necessary for all inputs declared with the <a href="http://twitter.com/Input">@Input</a> decorator where you don’t provide a default value for the input. The input declared with the signal input, though, doesn’t require any tricks to remove TypeScript errors or warnings. This is made even more useful when you mark an input as required.</p><pre>export class MyComponent {<br> @Input({ required: true }) name !: string;<br> firstName = input.required&lt;string&gt;();<br>}</pre><p>The decorator input still needs the definite assignment assertion, even though we’ve marked it as required. This improvement to type safety is a much appreciated improvement to our components.</p><p><strong>ngOnChanges</strong></p><p>Another benefit of using input signals is that you no longer need to use the ngOnChanges lifecycle hook. This hook has its uses, but it’s never been very developer friendly. It is triggered when the component is initialized and when an <a href="http://twitter.com/Input">@Input</a> is changed. You can then run some logic with the <a href="http://twitter.com/Input">@Input</a> of the component. Extracting the correct values though in the lifecycle hook was confusing and required several extra lines of code. With signals, though, you can use a computed signal, or an effect, and your component will automatically update if the signal input updates. Let’s look at an example to clarify this. First is an example of a component with decorator inputs, second is an example of signal inputs.</p><pre><br>export class UserProfileComponent implements OnChanges {<br>  @Input() firstName = ‘’;<br>  @Input() lastName = ‘’;<br> <br>  fullName = ‘’;<br> <br>  ngOnChanges(changes: SimpleChanges): void {<br>    // You have to check if the specific inputs changed<br>    if (changes[&#39;firstName&#39;] || changes[&#39;lastName&#39;]) {<br>      this.fullName = `${this.firstName} ${this.lastName}`;<br>    }<br>  }<br>}</pre><pre><br>export class UserProfileComponent {<br>  firstName = input(‘’);<br>  lastName = input(‘’);<br>  // Automatically updates whenever firstName or lastName changes<br>  // No lifecycle hooks required<br>  fullName = computed(() =&gt; `${this.firstName()} ${this.lastName()}`);<br>}</pre><p>The first example works fine, but it takes a lot more logic to get to the same point as the second example. Because of the way signals work, each time the firstName signal or lastName signal changes, the computed signal will automatically update, and our UI will reflect that change.</p><p><strong>Read-only Inputs</strong></p><p>Unlike decorator inputs, signal inputs are read-only. If your component needs to update the value of the input, which gives you two-way data binding between the components, you’ll need to use the model signal. It’s used in much the same way as a normal signal input:</p><pre><br>export class CounterComponent {<br>  count = model&lt;number&gt;(0);<br>  <br>  increment() {<br>    // Unlike input(), model() is writable<br>    this.count.update(c =&gt; c + 1);<br>  }<br>}</pre><p>This will automatically provide a value change output that the parent component can use to get updates about the value. In this case, the output would be named countChange, and you would likely listen to the output with the familiar “banana-in-a-box” syntax:</p><pre>&lt;app-counter [(count)]=”buttonClicks” /&gt;</pre><p>When the CounterComponent updates the count signal, the parent component will update as well.</p><p><strong>Data Transformation</strong></p><p>Another very useful feature of signal inputs is the ability to automatically transform data as it comes in the component. The transformation occurs <em>before</em> the data is stored in the value of the signal. This is useful when the data comes into your component through an HTML attribute. The value of those attributes is often a string, even if your intention is for it to be a different type. For example, maybe you want it to be a boolean or a number. You can use a transform to convert the value for you, and the result will be stored in the signal. Let’s look at an example.</p><pre>&lt;app-counter-display count=”displayNumber” showDetails=”true” /&gt;</pre><p>In this case, the value of the count attribute in the child component would be a string instead of a number, and the value of showDetails would be the string &#39;true&#39; rather than a boolean. We can coerce those values to the desired types with a transform:</p><pre>export class CounterDisplay {<br> count = input&lt;number&gt;(0, { transform: numberAttribute })<br> showDetails = input&lt;boolean&gt;(false, { transform: booleanAttribute })<br>}</pre><p>In this example, I’m using a couple of built in transform functions that convert an input to a number or boolean, respectively. If you need to write your own transform, provide a function that takes the value of the input as a parameter, and returns the value you want stored in the component.</p><h3>Signal Outputs</h3><p>Alright, you caught me. Technically speaking, there are no such things as signal outputs. But there is a new way to create outputs for your components that matches the style of using the signal inputs input() and model(). The output method returns an OutputEmitterRef, on which you still need to explicitly call .emit. You will also no longer need to instantiate an instance of EventEmitter when creating the output. Let’s look at a couple of examples to demonstrate these differences.</p><pre><br>export class UserCardComponent {<br>  // Requires decorator + explicit class instantiation<br>  @Output() deleteUser = new EventEmitter&lt;string&gt;();<br>  updateUser = output&lt;string&gt;();<br><br>  onDelete() {<br>    this.deleteUser.emit(&#39;user-123&#39;);<br>  }<br><br>  onUpdate() {<br>    this.updateUser.emit(&#39;user-123&#39;);<br>  }<br>}</pre><p>Again, the actual use of the output is essentially the same; the only real difference here is the instantiation of the two outputs. The parent would listen for the outputs in the same way as well.</p><pre>&lt;app-user-card <br>  (deleteUser)=”deleteUser($event)” <br>  (updateUser)=”updateUser($event)” <br>/&gt;</pre><blockquote>Earlier we talked about the model signal input, and how a value change output is automatically created. Angular essentially creates an output for you automatically in the same way that the demo is shown above.</blockquote><p><strong>outputFromObservable</strong></p><p>One final convenience that is provided is a way to output a value from the observable inside a component. For example, let’s say you have a SearchComponent that has a FormControl to do the search. Each time the value changes, you want to notify the parent of that change. Previously, you would have had to subscribe to the valueChanges observable of the FormControl and emit the new value on each change.</p><pre><br>export class SearchComponent implements OnInit, OnDestroy {<br>  // 1. Create the Output<br>  @Output() query = new EventEmitter&lt;string | null&gt;();<br>  <br>  searchControl = new FormControl(&#39;&#39;);<br>  private querySub?: Subscription;<br><br>  ngOnInit() {<br>    // 2. Manually subscribe to the stream<br>    this.querySub = this.searchControl.valueChanges.subscribe(value =&gt; {<br>      // 3. Manually emit the value<br>      this.query.emit(value);<br>    });<br>  }<br><br>  ngOnDestroy() {<br>    // 4. Manually clean up the subscription (The &quot;Subscription Tax&quot;)<br>    this.querySub?.unsubscribe();<br>  }<br>}</pre><p>All of this can be replaced with the following when we use the `outputFromObservable` method:</p><pre>export class SearchComponent {<br>  searchControl = new FormControl(&#39;&#39;);<br><br>  // Automatically emits the value whenever the form control changes<br>  query = outputFromObservable(this.searchControl.valueChanges);<br>}</pre><blockquote>Import outputFromObservable from the <a href="http://twitter.com/angular/core">@angular/core</a>/rxjs-interop package.</blockquote><p>This new feature simplifies our component drastically. We eliminate the lifecycle hooks and the manual subscription management, ensuring we never accidentally leave an open subscription that causes a memory leak. You don’t need to use the new signal inputs to benefit from this convenience. If you have this use case, start using this new function right away.</p><h3>Conclusion</h3><p>Angular just keeps getting better and more developer friendly. At the same time our apps benefit from better performance, with very little effort required on our part.</p><p>The great thing about this specific feature is that you don’t need to panic and update every component in your application. You can gradually update old components, while ensuring that new components use this new feature. As you go along, you’ll eventually update your application. You can also use the <a href="https://angular.dev/reference/migrations/signal-inputs">signal input migration generator</a> if you want to migrate everything all at once automatically. Whichever method works best for you is great.</p><p>Finally, by adopting these signal-based primitives now, you aren’t just saving a few lines of code; you are future-proofing your application and preparing it for the era of zoneless performance.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7d749dd5683a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ngconf/modernize-your-components-the-power-of-signal-inputs-and-outputs-7d749dd5683a">Modernize Your Components: The Power of Signal Inputs and Outputs</a> was originally published in <a href="https://medium.com/ngconf">ngconf</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Angular Resource API]]></title>
            <link>https://medium.com/ngconf/the-angular-resource-api-fe8fa2b538bf?source=rss-39b42ea5b9d4------2</link>
            <guid isPermaLink="false">https://medium.com/p/fe8fa2b538bf</guid>
            <category><![CDATA[signal]]></category>
            <category><![CDATA[angular]]></category>
            <dc:creator><![CDATA[Preston Lamb]]></dc:creator>
            <pubDate>Mon, 03 Nov 2025 13:01:58 GMT</pubDate>
            <atom:updated>2025-11-04T04:47:46.546Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Introduction</strong></h3><p>Signals have been a great introduction to Angular, perhaps one of the best received additions for many years. The reactivity that they provide for your API, and the simplicity with which you can use them, is the main reason for that. Initially the use case where you might make an API call but then place the results in a signal were somewhat clunky and unclear. However, the experimental <a href="https://angular.dev/api/core/Resource">Resource API</a> aims to fix these inconveniences.</p><h3><strong>The Main Problem</strong></h3><p>Experienced Angular developers will know this, but for those that may be new to the community, here’s a brief overview of how Angular apps make HTTP calls. Generally speaking, you will inject the HTTP Client from the framework. This service makes HTTP calls for you, using RxJS observables behind the scenes. The observable needs to be subscribed to for the call to be made, and the data comes back and can be fed through an RxJS pipeline to manipulate the data as needed before being used in your component.</p><p>Now, if you wanted to use the data from this HTTP call in a signal rather than an observable, you would need to manually do that. You might extract the data from the observable and update the signal, or use the toSignal method from @angular/core/rxjs-interop. This isn’t a very clean method of getting the data in signals, however, and may cause some issues for you down the road, in either functionality or maintainability. The good thing is that Angular is working on a new service, called the Resource API, that should handle most of this for us.</p><h3><strong>Angular Resource</strong></h3><p>The <a href="https://angular.dev/api/core/Resource">Resource API</a> is still experimental as of the time of this blog post (Angular 20.3), so some of the things mentioned here may have been updated or changed as it’s worked on. However, its purpose is to take an asynchronous dependency (some data from an API call, for example) and manage it through signals. Let’s look at using httpResource, which will feel very familiar since it’s based on the HttpClient.</p><h3><strong>httpResource</strong></h3><p>For our httpResource example, let’s look at a simple component that needs to get data from an API. All that is required for using the httpResource is a function that returns a URL, which will be used to request the data.</p><pre>import { httpResource } from &#39;@angular/common/http&#39;;<br><br>export class MyComponent {<br>  public pikachu = httpResource&lt;Pokemon&gt;(() =&gt; &#39;https://pokeapi.co/api/v2/pokemon/pikachu&#39;)<br>}</pre><p>In this example, we use httpResource to make the call to the Pokemon API to retrieve the data about Pikachu. The API is called and the result is automatically inserted into the signal. The resource (`pikachu`) also has some helper signals on it as well, like isLoading, error, and status, in addition to the `value` signal where the data resides. This makes it really easy to update the UI based on the status of the API call with the `pikachu` signal.</p><p>Now, this is nice and helpful, but many times we have some data that the API relies on to get the correct data from the API. The great thing is that httpResource will automatically make another call if a signal that it relies on is updated. Let’s look at our component again:</p><pre>import { httpResource } from &#39;@angular/common/http&#39;;<br>import { signal } from &#39;@angular/core&#39;;<br><br>export class MyComponent {<br>  public pokemonSearchTerm = signal(&#39;pikachu&#39;)<br>  public pokemon = httpResource&lt;Pokemon&gt;(() =&gt; `https://pokeapi.co/api/v2/pokemon/${this.pokemonSearchTerm()}`)<br>}</pre><p>In this case, we have a new signal, pokemonSearchTerm, which is initialized with ‘pikachu’. The API call is made with that value, and when the search term is updated, for example to ‘bulbasaur’, the API will be called again with the new value. Once again, the isLoading signal will return true and your UI can reactively be updated.</p><h3><strong>rxResource</strong></h3><p>rxResource is another helpful piece of the Angular Resource story. Many people out there have large applications that already have many data access services set up for getting data from their API. As such, it might make sense to not rewrite all the data access code. That’s where rxResource shines. This resource can take an RxJS-based call and convert it to a signal for you. Here’s another example of our initial component:</p><pre>import { rxResource } from &#39;@angular/core/rxjs-interop&#39;;<br><br>export class MyComponent {<br>  private pokeApiService = inject(PokeApiService);<br>  public pikachu = rxResource({<br>    stream: () =&gt; {<br>      return this.pokeApiService.getPikachu()<br>    }<br>  });<br>}</pre><p>In this example, we take an RxJS-based service that gets Pikachu’s information from the API, and which is then converted to a signal for us. All we need to do is return an RxJS observable from the stream option of rxResource. However, it’s not likely that we’ll call an API for just one specific item like this. Let’s update the example</p><pre>import { rxResource } from &#39;@angular/core/rxjs-interop&#39;;<br><br>export class MyComponent {<br>  public pokemonSearchTerm = signal(&#39;&#39;)<br>  private pokeApiService = inject(PokeApiService);<br>  public pikachu = rxResource({<br>    params: this.pokemonSearchTerm,<br>    stream: (params) =&gt; {<br>      if (!params.params) {<br>        return of(undefined);<br>      }<br>      <br>      return this.pokeApiService.searchPokemon(params.params)<br>    }<br>  });<br>}</pre><p>This is very similar to the last example, but we provide a params attribute to the options passed in to the rxResource, and assign it to our pokemonSearchTerm signal. If there is no value in the params, then we just return an observable with undefined as the value (which, this just so happens to be the default value of an rxResource). Otherwise, we take the search term and call the API. Just like with the httpResource, we are given signals on the rxResource for isLoading and value.</p><h3><strong>Quick Tips</strong></h3><p>There are a few things to note about the Resource API before we finish up.</p><ul><li>The first is that this API is only for retrieving data, not mutating it. That means only use it for GET requests, not POST or PUT or DELETE requests.</li><li>Another thing to note is that you can use a plain resource (instead of httpResource or rxResource) if you want to use the native fetch API instead of the HttpClient.</li><li>httpResource has a parse option that allows you to transform data and provide data validation if needed when the data comes back from the API and before it’s stored in your signal.</li><li>Last but not least, remember that this is experimental and can change at any time.</li></ul><h3><strong>Conclusion</strong></h3><p>Signals continue to grow in the Angular community, and become more and more prevalent. As such, tools like this will be provided by both the Angular team and the community to make the move to signals easier and more intuitive. Keep an eye on the Resource API as it moves out of experimental status and into stable.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fe8fa2b538bf" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ngconf/the-angular-resource-api-fe8fa2b538bf">The Angular Resource API</a> was originally published in <a href="https://medium.com/ngconf">ngconf</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Angular and Copilot Coding Agents]]></title>
            <link>https://medium.com/ngconf/angular-and-copilot-coding-agents-85522e55d621?source=rss-39b42ea5b9d4------2</link>
            <guid isPermaLink="false">https://medium.com/p/85522e55d621</guid>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[github-copilot]]></category>
            <dc:creator><![CDATA[Preston Lamb]]></dc:creator>
            <pubDate>Thu, 10 Jul 2025 22:33:47 GMT</pubDate>
            <atom:updated>2025-07-10T22:33:47.799Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>The last several months have been dominated by how AI will fit in our workflows and how we will implement it in our day to day life. This has left some feeling uneasy and worried; some are avoiding AI at all costs; still others are embracing the new tools. The truth is that AI is getting better every day at helping us with the mundane parts of our job and allowing us to focus on more challenging things. I think the best option is to embrace the tools we have and use them to the best of our abilities. In this article, we’ll look at one of those newer tools, GitHub Copilot’s Coding Agents, and how we can use them to assist us in our work.</p><h3>What are Copilot Coding Agents?</h3><p>Let’s start by discussing what the Copilot Coding Agents are. Coding agents are processes that Copilot can kick off that work on different tasks for you. <a href="https://docs.github.com/en/copilot/concepts/about-assigning-tasks-to-copilot">The documentation</a> lists the following things that the coding agents can accomplish for you:</p><ul><li>Fix bugs</li><li>Implement incremental new features</li><li>Improve test coverage</li><li>Update documentation</li><li>Address technical debt</li></ul><p>They are in public preview now, and can be used by those with the GitHub Copilot Pro, GitHub Copilot Pro+, GitHub Copilot Business and GitHub Copilot Enterprise plans. While they are in public preview, I can attest to the fact that they are very good at accomplishing the above use cases.</p><p>The easiest way I’ve found to get the coding agent working on a task for you is to create a GitHub issue and assign it to Copilot. At that point, the agent will create a PR and start a coding session. You’ll be able to view the session and the steps Copilot takes to accomplish the task. At the end of the session, you can go back to the PR and review it just like you would any other PR.</p><p>Copilot coding agents also differ from agent mode in VS Code. The document (linked above) says this about the differences:</p><blockquote><em>Copilot coding agent is distinct from the “agent mode” feature available in Visual Studio Code. Copilot coding agent works autonomously in a GitHub Actions-powered environment to complete development tasks assigned through GitHub issues or GitHub Copilot Chat prompts, and creates pull requests with the results. In contrast, agent mode in Visual Studio Code is part of the GitHub Copilot Edits feature that allows Copilot to make autonomous edits directly in your local development environment.</em></blockquote><h3>Assigning Issues to Coding Agents</h3><p>Now, these coding agents can accomplish some impressive tasks, and we’ll look at a few examples from my use shortly, but there are some things you need to know to make things go as smoothly as possible. The first and most important is that you need to be as clear as possible in what you want the agent to accomplish when assigning it the GitHub issue. I don’t know about you, but sometimes the tickets I get have something like the following as the description:</p><h4>Description</h4><p>The checkout process isn’t working. I tried to buy the new featured product, and it just failed. This is a huge problem because our big marketing campaign just launched, and we’re losing sales every minute this is down. It’s critical to the business that customers can check out. Please fix this ASAP! This is an emergency.</p><p>This description isn’t intentionally bad; a product owner may write something like this because they don’t have a technical background and they just know that something isn’t working and they need it to work. When a human gets a ticket description like this, we can reason our way through what might be going on. Maybe we wrote that feature, and we know where to go to start debugging. We may also have access to a logging system like DataDog or Sentry that will give us more context about the issue. The problem is that the coding agent doesn’t have any of that context. If you assign the above issue to the coding agent, it may be able to find the related components and services, and may be able to look for some obvious bugs, but it likely isn’t going to be able to solve the problem. However, if you assign the agent a task that looks like this, you’re more likely to be successful:</p><h4>Description</h4><p>When a user proceeds through the checkout flow as a guest and enters a valid United States shipping address, the final “Pay Now” button on the payment page becomes unresponsive. Clicking it produces no visual feedback or network activity. This issue has been confirmed on Chrome and Firefox but does not appear to affect logged-in users.</p><h4>Expected Result</h4><p>The “Pay Now” button should process the payment. The user should be shown a “Processing…” indicator, and upon successful transaction, be redirected to the order confirmation page.</p><p>This description is much more helpful, both for us as the developers, but also for an AI coding agent. We now know specifically what is happening, and what should happen. Assigning this issue to the coding agent makes it much more likely that the issue can be solved by the agent. However, I still like to take it a step further. We want to fix the bug, but we also want to ensure that the issue doesn’t happen again. Ideally we would add some unit and end to end tests to ensure that the issue doesn’t occur again in the future. These are things that we need to provide to the coding agent to ensure that it adds that to the PR. Here’s a good final issue description:</p><h4>Description</h4><p>When a user proceeds through the checkout flow as a guest and enters a valid United States shipping address, the final “Pay Now” button on the payment page becomes unresponsive. Clicking it produces no visual feedback or network activity. This issue has been confirmed on Chrome and Firefox but does not appear to affect logged-in users.</p><h4>Expected Result</h4><p>The “Pay Now” button should process the payment. The user should be shown a “Processing…” indicator, and upon successful transaction, be redirected to the order confirmation page.</p><h4>Acceptance Criteria</h4><ul><li>When a guest user clicks the “Pay Now” button with valid information, a payment processing request must be initiated.</li><li>The UI must provide clear feedback that the payment is being processed (e.g., a loading spinner, disabled button).</li><li>Upon a successful payment, the user must be redirected to the order confirmation page.</li><li>In the case of a payment failure, a clear and user-friendly error message must be displayed.</li><li>The fix must be functional across all supported browsers, including Chrome and Firefox.</li></ul><h4>Testing Plan</h4><p>Unit Tests (Angular)</p><ul><li>Payment Component (payment.component.ts):</li><li>Event binding for the payment submission button.</li><li>Component state changes during payment processing (e.g., loading and disabled states).</li><li>Proper interaction with the PaymentService upon submission.</li><li>Correct handling of successful payment responses, including navigation.</li><li>Correct handling of payment failure responses and error message display.</li><li>Payment Service (payment.service.ts):</li><li>Correct formation of the HTTP request to the guest payment endpoint.</li><li>Proper handling of both successful and error responses from the API.</li></ul><p>End-to-End Tests (Cypress)</p><ul><li>The complete, successful guest checkout flow, from adding an item to the cart to landing on the order confirmation page.</li><li>The guest checkout flow when a payment failure occurs, ensuring the correct error message is displayed and the user can attempt to pay again.</li></ul><p>Now our ticket has a clear description, acceptance criteria, and a testing plan that should be implemented to ensure we fix the issue going forward. This is an issue that a Copilot coding agent could take and have a reasonable chance at successfully solving.</p><h3>Issue Tips</h3><p>Just a tip: use AI to format your GitHub Issues! Seriously, do it. If you have access to the Copilot coding agents, you have Copilot on your GitHub account. Click on the Copilot icon:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*D220lfsSwpxowmIHOTB12g.png" /><figcaption>The Copilot button in GitHub’s web app</figcaption></figure><p>If you click this button while you’re on the homepage of a repo, it will use that repo as context for the questions you ask it. I will usually write the description out as clearly as I can, and then use a prompt similar to the following:</p><blockquote><em>Create a GitHub issue for the following, adding a testing plan and acceptance criteria …</em></blockquote><p>Copilot will then start creating the issue inline for you in the chat. You can review what it creates, make updates as needed, and ensure that everything you’re hoping for is covered. Once you’re satisfied with the issue, you can save it right there and assign it to Copilot.</p><h3>Copilot Coding Agent in Action</h3><p>Once the issue has been assigned to Copilot, you’ll see a PR created almost immediately. Open it up, and you’ll see a button that says “View Session”. This will take you into a view that looks a lot like the overview of a GitHub action for your CI. As the agent works through your ticket, it will log out each step, and tell you what it’s doing. There will be npm install steps, steps where it tells you that it is trying to understand the context of the repo, steps where it is making the change, steps where it is testing the changes made, and steps where it is finishing up.</p><p>I can’t provide an exact picture of this, because the times I’ve used this have been on private software for my company, but the UI is very intuitive and it’s easy to follow along with what is happening.</p><p>When the session is done, which I’ve seen take anywhere from ten minutes to 40 minutes, you’ll be able to review the PR just like you’re used to. You can review the changes made and ensure that everything looks good. This doesn’t mean, though, that the issue will be fixed after the first session. In fact, I think most of the time I’ve done this it’s taken a few sessions at least. If you notice something isn’t correct, you can comment on the PR with what you see, and Copilot will kick off another session and begin working on it again. For example, maybe it used *ngIf and you want to use the new control flow syntax. Write that in a comment (mention @copilot if you want to be more explicit) and then watch as the change is made. Continue this until you are reasonably sure that the issue is fixed.</p><h3>Manual Review</h3><p>The next step is pulling down the code and manually testing the change. The agent has done a really good job for me, but I have done this each time I’ve used it on an issue. I will pull the code down and run the app, and then manually test the feature. After I confirm that it works, I’ll review and run the unit and end to end tests. We use Nx at work, and I’ve also noticed that I’ve needed to run nx format:write and push those changes up for our CI to run successfully.</p><p>Now that the PR has been created, the work finished and manually tested, you can merge the PR and let your CI process take over from there. At this point, it’s just a normal PR that you open and close every day.</p><h3>Why Use Coding Agents</h3><p>Now let’s talk about why you might use these coding agents instead of doing the work on your own. The first reason is because AI is really efficient at solving straightforward coding problems like these ones. Like I mentioned above, I’ve seen coding agents solve problems in anywhere from 10 to 40 minutes, and those same tickets would have taken me anywhere from a couple hours to a day to accomplish on my own. While the agent is working on these tickets, I work on testing other tickets, or doing the really simple things like button color changes or text changes that I don’t think are worth assigning an agent to. This process has allowed me to implement features on our API that are above and beyond my skillset, and have also allowed me to implement new functionality in features that I haven’t worked on for several months. That second part is especially valuable, because when I come back to a feature that I haven’t worked on for several weeks or months, I need some time to re-familiarize myself with the code to actually make the change. The coding agent, though, is more efficient at understanding the context of the change and takes only a couple minutes to do what might take me a half hour to do.</p><p>These coding agents can also take on a wide variety of tasks, as mentioned above. I’ve used it for extending functionality in existing Angular features, as well as adding new functionality on our API. It’s done really well in all situations. In fact, on one issue I uploaded a rough mock of what the business wanted the feature to look like, and the agent was able to analyze the image and recreate it in HTML, matching our use of tailwind by using the context from other templates. I also used agents to implement a feature on the API that took the ID of a record, and tried to find possibly related or duplicate records based on provided criteria. It came up with the endpoint, the service method, the DTOs, the scoring criteria, and the documentation. It took a little tweaking here and there, but the majority of the work was done in under an hour. It was a feature that would have taken me a day to accomplish, at least. While the agent worked on that, I prepped the front end to call the new endpoint and display the data that would be returned. Overall, the coding agents have made me much more efficient and allowed us to close more tasks with the same number of developers on the project.</p><h3>Angular Specific Notes</h3><p>I do want to mention a couple things that are Angular specific as far as these coding agents go. When I’ve assigned the agent an API task (our API is written in .NET Core), I find that it does a pretty good job matching our existing standards and coding to those standards, including when writing unit and integration tests. But I have found that I need to be a little more explicit in how I want the Angular code to look. I imagine this is because the training dataset for modern Angular is smaller than that of C#. The agent still does a good job, but I have had to be explicit about using the new control flow syntax, telling it where to break pieces out into new components, and similar items to that. Those extra directions have made the resulting code better match what our Angular code looks like and match our coding standards.</p><h3>Conclusion</h3><p>Just like anything related to AI today, you should not just blindly accept the code generated by these coding agents. Double check the code it produces. Have a coworker or co-maintainer review the code in addition to your review. Manually test things before deploying them. It’s no different really than any code you use in your app that you didn’t write yourself. However, I can promise you that as you embrace what AI can do for you, you will become a more efficient developer, and your skillset will grow. Even though I’ve had the agents helping me on a lot of my backend tickets, I have learned a lot by reviewing the code it produces for me. I have started to learn some patterns and techniques, I have reviewed the generated tests and learned some good practices for those tests. These are things that I would have eventually learned anyways, but I am able to learn while also still providing a lot of value to my team.</p><p>Don’t be afraid of AI. It’s not going anywhere. Instead, use it to your advantage, just like you would any other tool. You likely wouldn’t turn down a better editor just because it makes things easier (otherwise we’d all just be using Notepad instead of IDEs to develop), and AI tools like this are no exception.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=85522e55d621" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ngconf/angular-and-copilot-coding-agents-85522e55d621">Angular and Copilot Coding Agents</a> was originally published in <a href="https://medium.com/ngconf">ngconf</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Angular Signals in Practice]]></title>
            <link>https://medium.com/ngconf/angular-signals-in-practice-165947bcafd4?source=rss-39b42ea5b9d4------2</link>
            <guid isPermaLink="false">https://medium.com/p/165947bcafd4</guid>
            <category><![CDATA[angular-signals]]></category>
            <category><![CDATA[angular]]></category>
            <dc:creator><![CDATA[Preston Lamb]]></dc:creator>
            <pubDate>Thu, 24 Apr 2025 12:37:00 GMT</pubDate>
            <atom:updated>2025-04-24T12:37:00.831Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Introduction</strong></h3><p>Signals have been around in Angular for a while now. But if you are like me, you might still be unsure when or why to use them. I understand how I declare them, update them, output their values in the template, etc. But I have been unsure sometimes <em>when</em> to use them. However, recently I ran into a situation where I refactored a piece of code from using a BehaviorSubject to using signals. In this post, I’ll show my previous implementation using RxJS, and then the refactored version with Signals.</p><h3><strong>Overview of the Situation</strong></h3><p>Before we jump in to the code, let’s review what this use case is. I work for an insurance company, and we want to make sure that when users are idle on our site for a certain amount of time, they are automatically logged out of the site. We don’t want them to accidentally stay logged in and give access to someone that shouldn’t have access to the site. We’re using a library called ng-idle to determine if the person is idle or not.</p><p>In the application, we initialize the idle watch, and then use Angular’s reactivity to show a modal several seconds before they are logged out. If they become active again, the modal is hidden. If they don’t, they are logged out. This example will look at one example where the modal is shown due to the value in a BehaviorSubject vs the value of a signal.</p><p>What this blog post is <em>not</em> is a decree about which format is better. They both work well and are inherently reactive. But it does give you an example of when you might use Signals instead of RxJS and a clear example of the difference in the code in the two situations.</p><h3><strong>BehaviorSubject</strong></h3><p>In our initial version of the idle user feature, we used a BehaviorSubject to contain how much time was left remaining before the user was logged out. ng-idle provides an EventEmitter, onIdleTimeoutWarning, that fires and emits a number. That number is the amount of time remaining before the user has been idle too long. Our component looks like this when handling that value:</p><pre>// app.component.ts<br><br>private idleTimeRemainingBs: BehaviorSubject&lt;number&gt; = new BehaviorSubject&lt;number&gt;();<br>public idleTimeRemaining$: Observable&lt;string&gt; = this.idleTimeRemainingBs.asObservable().pipe(<br> filter((val) =&gt; !!val),<br> map((time: number) =&gt; {<br>  if (time / 60 &gt; 1) {<br>   return `${Math.ceil(time / 60)} minutes`;<br>  }<br><br>  return `${time} seconds`;<br> })<br>)<br><br>ngOnInit() {<br> this._idle.onIdleStart.pipe(<br>  untilDestroyed(),<br>  tap(() =&gt; {<br>   this.showIdleModal = true;<br>  })<br> ).subscribe();<br><br> this._idle.onIdleEnd.pipe(<br>  untilDestroyed(),<br>  tap(() =&gt; {<br>   this.showIdleModal = false;<br>  })<br> ).subscribe();<br><br> this._idle.onIdleTimeoutWarning.pipe(<br>  untilDestroyed(),<br>  tap((time: number) =&gt; {<br>   this.idleTimeRemainingBs.next(time);<br>  })<br> ).subscribe()<br>}</pre><p>Let’s break this code down really quick. The first line declares and initializes the BehaviorSubject. It’s kept private and not able to be used in the template. Then an observable is created that either returns the number of minutes or the number of seconds remaining until the timeout is reached. This observable is what is used in the template.</p><p>In the ngOnInit lifecycle method, we use three methods from the Idle service. The first is when the Idle monitoring starts, and the second is when it ends. When either event fires, we show or hide the modal that tells the user how much time they have left. The final method is onIdleTimeoutWarning. When it fires, we take the number emitted and call .nex() on our BehaviorSubject, which then automatically updates the observable.</p><p>When the modal is visible, the idleTimeRemaining$ observable is subscribed to in the template with an async pipe, and the amount of time left before logout is shown on the screen. It’s pretty straightforward, with some definite room for improvement, but it also does get the job done. Now let’s look at the same functionality implemented with Signals.</p><h3><strong>Signal</strong></h3><p>There is some overlap with the code in this example, so I’m only going to show the differences. The onIdleStart and onIdleEnd pieces are the same. The difference is in the storing and displaying of the amount of time left before being logged out.</p><pre>// app.component.ts<br><br>private idleTimeRemainingSignal = signal&lt;number | null&gt;(null);<br>public idleTimeRemaining = computed(() =&gt; {<br> const time = this.idleTimeRemainingSignal();<br><br> if (time === null) {<br>  return &#39;&#39;;<br> }<br><br> if (time / 60 &gt; 1) {<br>  return `${Math.ceil(time / 60)} minutes`;<br> }<br><br> return return `${time} seconds`;<br>})<br><br>ngOnInit() {<br> this._idle.onIdleTimeoutWarning.pipe(<br>  untilDestroyed(),<br>  tap((time: number) =&gt; {<br>   this.idleTimeRemainingSignal.set(time);<br>  })<br> ).subscribe()<br>}</pre><p>Not a whole lot different, really. The only difference is that we are using a writable signal to keep track of how much time is remaining, and a computed signal to display that time to the user in the modal. Basically everything else is the same, and just like in the other situation, there is room for improvement.</p><h3><strong>So What?</strong></h3><p>So, what’s the point of this blog post and this refactor? My whole purpose really is to show an example of a time when you could use signals versus using RxJS, and how you’d go about doing that. They have the same result. It’s just two ways of doing things. But when you’re first starting to use signals, you might find yourself confused about when you’d use them. If you’re like me and have been using RxJS for a long time and worked hard to learn it at a deep level, you might have a hard time understanding what to do here. I hope this example helps.</p><h3><strong>Conclusion</strong></h3><p>In the end, it really doesn’t matter what you use. However, Signals are the way of the future and the newer way of writing Angular. <a href="https://angular.dev/guide/signals/linked-signal">LinkedSignals</a>, <a href="https://angular.dev/api/core/input#">Signal Inputs</a>, and using the <a href="https://angular.dev/guide/signals/resource">Resource API</a> are all examples of how Signals are becoming more and more a part of the framework. Understanding how to use them and when to use them is vital as you move forward with Angular.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=165947bcafd4" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ngconf/angular-signals-in-practice-165947bcafd4">Angular Signals in Practice</a> was originally published in <a href="https://medium.com/ngconf">ngconf</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ViewChild: Calling the Public API of a Child Component]]></title>
            <link>https://medium.com/ngconf/viewchild-calling-the-public-api-of-a-child-component-56881e58e6ba?source=rss-39b42ea5b9d4------2</link>
            <guid isPermaLink="false">https://medium.com/p/56881e58e6ba</guid>
            <category><![CDATA[parent-component]]></category>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[child-component]]></category>
            <category><![CDATA[ngconf]]></category>
            <dc:creator><![CDATA[Preston Lamb]]></dc:creator>
            <pubDate>Thu, 09 Nov 2023 14:36:44 GMT</pubDate>
            <atom:updated>2023-11-09T14:36:44.444Z</atom:updated>
            <content:encoded><![CDATA[<h3>tldr;</h3><p>Sometimes we need to interact with a child component from a parent component, but it’s not viable to do so through Inputs. ViewChild allows you to gain access to the child component and call methods from its public API as needed.</p><h3>Background</h3><p>I was recently working on a project where I needed to use our custom AccordionComponent. The toggle to show and hide the body content of the accordion is contained within the component. The design, though, needed me to move the toggle to a different location. This wasn’t possible to do in the component, as there are too many edge cases for where you might want to put the trigger. I wanted to find a way that would give me the flexibility to put the trigger anywhere I needed, as well as the simplicity of having it provided when needed as well.</p><h3>What is ViewChild?</h3><p>There is a decorator in Angular called ViewChild which gives you access in the component’s TypeScript class to a piece of the template. It will look for the first element in the template that matches the selector, and if the view is updated the reference will update as well.</p><p>There are a few ways to select the item you need on the page. The first is via a template variable. Let’s say you have the following HTML:</p><pre>&lt;button #myBtn&gt;&lt;/button&gt;</pre><p>In this case, we have a button element with the template variable #myBtn. If we needed access to this in the TypeScript file, we could do that with the following code:</p><pre>@ViewChild(&#39;myBtn&#39;) myButton: ElementRef;</pre><p>After gaining access to the button, we could interact with it as needed in the TypeScript file.</p><p>Another way to select something is by adding a service in the parentheses of the ViewChild decorator. If you use a service there, it will select the service in the child component tree. I’ve never used it in this way, but if your child component had a singleton service and the parent needed access to it for some reason, this would help you get access to that service.</p><p>The last way that I’ll cover to use the selector is by adding a component or directive class name inside the parentheses:</p><pre>@ViewChild(AccordionComponent) accordion: AccordionComponent;</pre><p>In this case, Angular will find the first instance of the AccordionComponent and put that reference inside the accordion variable.</p><h3>Using ViewChild in the Parent Component</h3><p>Back to my situation that I described above. I needed to use the accordion component, but wanted a custom trigger. The component uses content projection, so I could provide the trigger easily, I just needed to hook up its click handler to the AccordionComponent so that it opened and closed as desired. Here’s the HTML:</p><pre>&lt;app-accordion&gt;<br>  &lt;ng-container accordion-header&gt;<br>    &lt;div class=&quot;flex justify-between&quot;&gt;<br>      &lt;p&gt;Accordion Header Title&lt;/p&gt;<br>      &lt;button (click)=&quot;handleAccordionTriggerClick()&quot;&gt;Accordion Trigger&lt;/button&gt;<br>    &lt;/div&gt;<br>  &lt;/ng-container&gt;<br>  &lt;ng-container accordion-body&gt;<br>    &lt;!-- Accordion Body --&gt;<br>  &lt;/ng-container&gt;<br>&lt;/app-accordion&gt;</pre><p>All I’ve done is added the accordion to the template of my component. Now, getting access to the accordion so I can open it is done like this:</p><pre>export class ParentComponent {<br>  @ViewChild(AccordionComponent) accordion!: AccordionComponent;<br>  <br>  public toggleCollapsedStatus() {<br>    this.accordion.toggleCollapsedStatus();<br>  }<br>}</pre><p>With this method, the AccordionComponent still manages the state of the accordion, and I can decide where the trigger is located and what it looks like. It’s the best of both worlds as far as flexibility and component isolation goes.</p><h3>Conclusion</h3><p>If you need to interact with the public API of a child component, ViewChild is your answer. It allows you to interact with the child component without only using Inputs. Combined with content projection, I’ve been able to make my AccordionComponent as reusable as possible.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=56881e58e6ba" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ngconf/viewchild-calling-the-public-api-of-a-child-component-56881e58e6ba">ViewChild: Calling the Public API of a Child Component</a> was originally published in <a href="https://medium.com/ngconf">ngconf</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Developing Angular Components with Cypress Component Tests]]></title>
            <link>https://medium.com/ngconf/developing-angular-components-with-cypress-component-tests-956efe847ba7?source=rss-39b42ea5b9d4------2</link>
            <guid isPermaLink="false">https://medium.com/p/956efe847ba7</guid>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[component-testing]]></category>
            <category><![CDATA[e2e-testing]]></category>
            <category><![CDATA[cypress]]></category>
            <category><![CDATA[ngconf]]></category>
            <dc:creator><![CDATA[Preston Lamb]]></dc:creator>
            <pubDate>Thu, 28 Sep 2023 12:21:32 GMT</pubDate>
            <atom:updated>2023-09-28T12:21:32.363Z</atom:updated>
            <content:encoded><![CDATA[<h3>tldr;</h3><p>Developing UI components for our apps can be difficult. They require different inputs, or you may have to fill out a long form to see it, or have specific data come back from the API to see the component. But using a tool like Cypress’s component tests can simplify it by isolating the UI component so you can develop it without a lot of setup.</p><h3>What are Cypress Component Tests</h3><p>Let’s take just a minute to talk about what Cypress component tests are. They are relatively new to the ecosystem, and many people probably haven’t used them. Essentially, these tests are similar to a full Cypress e2e test, in that it takes a component and actually loads it into a browser instance. You can see what it will look like when used in your app. You can test interactions, display functionality, etc. You can provide different inputs, mock services, etc. The same great developer experience you get in Cypress e2e tests exists with the component tests.</p><p>Cypress component tests can be used in conjunction with or as a replacement for the default tests that are created for Angular components. I like to use both of them, with the default tests being more unit test oriented, and Cypress component tests looking at the component in the browser and ensuring a user can interact with it properly.</p><p>Here’s an example of a Cypress component tests:</p><pre>describe(MyComponent.name, () =&gt; {<br>  it(&#39;renders the component&#39;, () =&gt; {<br>    cy.mount(MyComponent, {<br>      imports: [],<br>      componentProperties: {<br>        myInput: &#39;my-input-value&#39;,<br>      },<br>      providers: [],<br>    });<br>  });<br>})</pre><p>In this test, Cypress mounts the component. If it is able to, the test passes. You can then add other checks and tests below the cy.mount(). You can import any dependencies the component needs and add them to the imports array, or any providers needed, or the value for any inputs the component is looking for.</p><p>To get started with Cypress’s component tests, <a href="https://docs.cypress.io/guides/component-testing/angular/overview">check out their documentation</a>.</p><h3>Developing Components with Cypress</h3><p>One way that I find Cypress component tests helpful is when needing to change the design of a component. Recently, I had a UI component that had a need for a new design. The process of getting to the point in the app where the component shows up takes a minute to reach, so every time you make a change you have to fill out a form and click next a few times. I didn’t want to do that for each change. So I created a Cypress component test for the component, and opened it up. As I changed the design, I could easily check it until it was correct. Once the design was complete, I could go to the full app and check it in there and ensure that the app still worked as expected.</p><p>In my case, I was just working with the design only. There wasn’t much I needed to do in terms of checking functionality of the component. However, I have a custom accordion component that has several Cypress tests written on it. If we decided to change how it displays, those tests would come in very important. As long as the tests keep passing, I won’t have to go to every place the component is implemented and ensure I didn’t break anything.</p><h3>Conclusion</h3><p>There are a lot of ways to develop your Angular components, and this is just one of my favorite ways. The easier it is to make changes to your app, with confidence that you haven’t broken anything, the better.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=956efe847ba7" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ngconf/developing-angular-components-with-cypress-component-tests-956efe847ba7">Developing Angular Components with Cypress Component Tests</a> was originally published in <a href="https://medium.com/ngconf">ngconf</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Functional CanDeactivate Guards in Angular]]></title>
            <link>https://medium.com/ngconf/functional-candeactivate-guards-in-angular-2211f5da78c2?source=rss-39b42ea5b9d4------2</link>
            <guid isPermaLink="false">https://medium.com/p/2211f5da78c2</guid>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[route-guards]]></category>
            <category><![CDATA[ngconf]]></category>
            <dc:creator><![CDATA[Preston Lamb]]></dc:creator>
            <pubDate>Thu, 10 Aug 2023 14:27:45 GMT</pubDate>
            <atom:updated>2023-08-10T14:27:45.606Z</atom:updated>
            <content:encoded><![CDATA[<h3>tldr;</h3><p>CanDeactivate guards in Angular can be very helpful in your app. Preventing users from leaving a route can keep the user from losing their progress on a form or something similar. Angular makes it easy with the CanDeactivate guard, and they’re even more straight-forward to write with the (not-so-new anymore) format of functional guards.</p><h3>Creating the Guard</h3><p>First, create the guard either manually or with the Angular or Nx CLI. If you use the CLI, make sure to select that you want to implement the CanDeactivate interface. Once the guard is corrected, you can start working on the guard. There are a few pieces you’ll need to add for the guard, so let’s walk through each piece.</p><p>The first is not actually necessary, but it is helpful, and that is to create a type that we can use to refer to the return type of the guard. All this will do is make it easier to refer to the return type in our code.</p><pre>export type CanDeactivateType = Observable&lt;boolean | UrlTree&gt; | Promise&lt;boolean | UrlTree&gt; | boolean | UrlTree;</pre><p>The types listed here are all options for the CanDeactivate guard to return. We’ll use this in a couple spots, but again it’s unnecessary.</p><p>The next step is to create an interface that we’ll use for the generic argument of the guard. Essentially, this is going to say that the component that the guard is applied to could have a canDeactivate method that the guard will call to see if the component can be deactivated.</p><pre>export interface CanComponentDeactivate {<br>  canDeactivate: () =&gt; CanDeactivateType;<br>}</pre><blockquote><em>Calling the method </em><em>canDeactivate is just an example. You could call it whatever you want, but </em><em>canDeactivate makes it very easy for everyone to know what is going on.</em></blockquote><p>Finally, we actually have the guard to write. The function will return a CanDeactivateFn, with the generic type of CanComponentDeactivate.</p><pre>export const canDeactivateGuard: CanDeactivateFn&lt;CanComponentDeactivate&gt; = (component: CanComponentDeactivate) =&gt; {<br>  return component.canDeactivate ? component.canDeactivate() : true;<br>};</pre><p>The guard function can accept other parameters as well. Those parameters are currentRoute: ActivatedRouteSnapshot, currentState: RouterStateSnapshot, and nextState: RouterStateSnapshot. In many simple cases, you’ll just need to call the canDeactivate method on your component (if it exists) as shown above.</p><p>At this point, the guard is ready to implement.</p><h3>Implementing the Guard</h3><p>After creating the guard we need to actually implement it. The first step is to add the guard to the route definition. All that’s needed is to add a canDeactivate array to the route definition with the guard added to the array.</p><pre>{ path: &#39;my-route&#39;, component: MyRouteComponent, canDeactivate: [canDeactivateGuard] },</pre><p>In the component’s Typescript file, we implement the canDeactivate method. This method will return one of the types on our CanDeactivateType. If the result is true, the user will be able to leave the page. If the result is false, the navigation is cancelled and the user stays on the page. This is slightly tricky if you want to get the user’s feedback before staying or routing away from the page. In this situation, just create a Subject and return it. Then show the user a prompt, and call the next method on the subject with the result of the user’s selection.</p><pre>canDeactivate(): CanDeactivateType {<br>  if (this.promptUser) {<br>    const deactivateSubject = new Subject&lt;boolean&gt;();<br>    this._confirmation.confirm({<br>      message: &#39;Are you sure you want to leave? Some data may be lost.&#39;,<br>      icon: &#39;&#39;,<br>      accept: () =&gt; {<br>        deactivateSubject.next(true);<br>      },<br>      reject: () =&gt; {<br>        deactivateSubject.next(false);<br>      },<br>    });<br>    return deactivateSubject;<br>  } else {<br>    return true;<br>  }<br>}</pre><blockquote><em>The </em><em>_confirmation.confirm here comes from PrimeNg. However, you can use whatever process you want for your situation.</em></blockquote><p>Now when you’re on this route, and try to route away, the canDeactivate method will be called. If it returns true the user will be able to change routes. Otherwise they will stay on the page.</p><h3>Testing the Guard</h3><p>The last piece of implementing the guard is testing it. This step is a lot easier now with the RouterTestingHarness and HttpClientTestingModule. You can read more about functional route guards and how to test them <a href="https://medium.com/ngconf/functional-route-guards-in-angular-8829f0e4ca5c">in this previous article of mine</a>. In this article I’ll simply show you how to test this type of guard.</p><p>For the tests, we’ll create a few test components which we’ll configure as routes that we will “route” to and from in the tests. The components should represent different options that your application might have. For example, one component can return false for the canDeactivate method, one returns true, and one that doesn’t implement the method. This way in the tests you can start on a row, trigger a navigation event, and then check to see where the application ends up. Below is an example of the tests.</p><pre><br>@Component({ standalone: true, template: &#39;&#39; })<br>class HasCanDeactivateTrueComponent {<br>  canDeactivate() {<br>    return true;<br>  }<br>}<br>@Component({ standalone: true, template: &#39;&#39; })<br>class HasCanDeactivateFalseComponent {<br>  canDeactivate() {<br>    return false;<br>  }<br>}<br>@Component({ standalone: true, template: &#39;&#39; })<br>class HasNoCanDeactivateComponent {}<br>@Component({ standalone: true, template: &#39;&#39; })<br>class DashboardComponent {}<br><br>describe(&#39;canDeactivateGuard&#39;, () =&gt; {<br>  let routes: Route[] = [];<br>  beforeEach(() =&gt; {<br>    routes = [<br>      { path: &#39;can-deactivate&#39;, canDeactivate: [canDeactivateGuard], component: HasCanDeactivateTrueComponent },<br>      { path: &#39;cant-deactivate&#39;, canDeactivate: [canDeactivateGuard], component: HasCanDeactivateFalseComponent },<br>      { path: &#39;no-guard&#39;, canDeactivate: [canDeactivateGuard], component: HasNoCanDeactivateComponent },<br>      { path: &#39;dashboard&#39;, component: DashboardComponent },<br>    ];<br>  });<br>  it(&#39;should allow the component to deactivate&#39;, async () =&gt; {<br>    TestBed.configureTestingModule({<br>      imports: [HttpClientTestingModule],<br>      providers: [provideRouter(routes)],<br>    });<br>    const testRouter = TestBed.inject(Router);<br>    await RouterTestingHarness.create(&#39;/can-deactivate&#39;);<br>    await testRouter.navigateByUrl(&#39;dashboard&#39;);<br>    expect(testRouter.url).toEqual(&#39;/dashboard&#39;);<br>  });<br>  it(&#39;should allow the component to deactivate&#39;, async () =&gt; {<br>    TestBed.configureTestingModule({<br>      imports: [HttpClientTestingModule],<br>      providers: [provideRouter(routes)],<br>    });<br>    const testRouter = TestBed.inject(Router);<br>    await RouterTestingHarness.create(&#39;/no-guard&#39;);<br>    await testRouter.navigateByUrl(&#39;dashboard&#39;);<br>    expect(testRouter.url).toEqual(&#39;/dashboard&#39;);<br>  });<br>  it(&#39;should prevent the component from deactivating&#39;, async () =&gt; {<br>    TestBed.configureTestingModule({<br>      imports: [HttpClientTestingModule],<br>      providers: [provideRouter(routes)],<br>    });<br>    const testRouter = TestBed.inject(Router);<br>    await RouterTestingHarness.create(&#39;/cant-deactivate&#39;);<br>    await testRouter.navigateByUrl(&#39;dashboard&#39;);<br>    expect(testRouter.url).toEqual(&#39;/cant-deactivate&#39;);<br>  });<br>});</pre><p>In these few tests, we can check to make sure that our guard is working properly.</p><h3>Conclusion</h3><p>CanDeactivate guards have their place, although you may want to be careful about using them too frequently; users generally know when they want to change routes and when they don’t. Angular makes it really easy to implement and test this functionality.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2211f5da78c2" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ngconf/functional-candeactivate-guards-in-angular-2211f5da78c2">Functional CanDeactivate Guards in Angular</a> was originally published in <a href="https://medium.com/ngconf">ngconf</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Analog: Angular’s Meta Framework]]></title>
            <link>https://medium.com/ngconf/analog-angulars-meta-framework-8b93dbec680f?source=rss-39b42ea5b9d4------2</link>
            <guid isPermaLink="false">https://medium.com/p/8b93dbec680f</guid>
            <category><![CDATA[ngconf]]></category>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[analog]]></category>
            <dc:creator><![CDATA[Preston Lamb]]></dc:creator>
            <pubDate>Thu, 13 Jul 2023 16:16:41 GMT</pubDate>
            <atom:updated>2023-07-13T16:16:41.796Z</atom:updated>
            <content:encoded><![CDATA[<h3>tldr;</h3><p>I recently rebuilt my personal site using Analog. This article will talk a little about what Analog is, as well as some of my notes on the experience and things that you should look for. Overall, though, you should know that Analog is a really cool project that I think will bring a lot of value to the ecosystem. It’s approachable, so you can use what you need at first and then adopt more of the features later on. You should definitely check it out!</p><h3>What is Analog?</h3><p>Analog is a powerful meta-framework for Angular that enables developers to build Angular apps with some of the latest and greatest JavaScript ecosystem features. In addition, you get things like server side rendering and static site generation with very little effort on your part.</p><p>Analog is like meta frameworks for other frontend frameworks like Vue and React. In many ways it’s just like the Angular you are familiar with. There are just a handful of different conventions that you pick up as you go along. We’ll talk about a few here, although I’m sure I’ll encounter more as I go along.</p><h3>File-based Routing</h3><p>The first thing I ran into that’s done differently from a standard Angular app is the file-based routing convention. In a normal Angular app, you would configure the routing module and declare routes and which component a particular route uses. In an Analog app, you use a file layout that automatically creates the route and ties it to the component in the file.</p><p>In the app’s folder structure when you generate your Analog app is a pages directory. Any component that is created and placed in that folder and ends in .page.ts will be turned into a route. The component in the folder will be generated for that route. You can have static and dynamic routes defined in the folder. You can also have nested routing configuration.</p><p>You can view more about routing in <a href="https://analogjs.org/docs/features/routing/overview">the documentation here</a>. As someone who doesn’t care that much about routing, and doesn’t have an issue with the normal Angular router and way of declaring routes, I still found that I liked the file-based routing. It makes it very clear what component handles which route. That can be a little hard to determine in a normal Angular app.</p><h3>Content Routes/Pages</h3><p>A major use case for Analog is creating sites with static or server-rendered content. Think of a marketing page or a blog. A comfortable, convenient way to write blog posts is by using Markdown. Analog has support for these types of pages built in. You can create normal routes in Markdown (like an about page or something) or blog posts. For blog posts, for example, you put the files in a content folder inside the app’s src folder. These will automatically be picked up and rendered when you define a route to the pages.</p><p>In my case, the main use of my site is for my blog. I added all my blog posts to /src/content/blog. I then defined a blog listing page at /app/pages/blog.page.ts. That page lists the blog posts. Each individual post is rendered by defining the /app/pages/blog.[slug].page.ts route. The [slug] part of the route is a route parameter, and the slug is used to find the particular blog post.</p><p>The markdown for the blog posts is rendered using an analog-markdown component that’s provided for you. If you use a Markdown file as a content route, it will be automatically rendered without any other needed configuration.</p><p>Another great feature is that you can have many different types of content files (i.e. blog posts) in the src/content folder, just organized in different subfolders. I’ve seen examples of blog posts, speaking opportunities, and code snippets all being saved in and rendered from the content files folder.</p><h3>Other Notes on Analog</h3><p>I was a little nervous about getting started with Analog. This had nothing to do with Analog, but because I have not done really any framework work outside of Angular in my ~10 years of being a professional developer. I have become very comfortable with how to develop apps using the Angular CLI or, more recently, Nx. So picking up something new made me a little nervous. But I really didn’t need to be. Working in Analog feels very much like working in a normal Angular app. Here are some things that I noticed that I liked while working with Analog:</p><ul><li>First and foremost: it’s fast. There is very little time between saving the file and it reloading in the browser. This is nice because any time saved debugging issues is nice.</li><li>Self closing tags (&lt;app-my-page /&gt;) is a nice touch. I don’t think this is unique to Analog, I remember hearing some talk of this in Angular recently, but I had forgotten about it. It is a nice tough, although not a huge time saver.</li><li>Not setting up the router and only using standalone components simplifies development a lot. Standalone is another thing that’s not unique to Analog, but combined with simplified routing makes getting your app up and running that much quicker.</li><li>I like the flexibility of being able to use Markdown. I write a lot of blog posts, and not needing to write the HTML myself for the blog posts, or do a lot of complicated setup, is really nice.</li><li>I still need to learn the best way to organize my app. I have been very used to doing it the way Nx prescribes, so learning a new organization standard is leaving me feel a little lost. However, this is not an Analog problem, it’s a me problem. And it’s really not a problem either. But I ran into it on an Ionic project recently as well.</li><li>It’s young. There are still some features that exist in other meta frameworks like Next or Gatsby that aren’t in Analog. So it might not have everything you need right away. But it seems to have most of it. And contributors are always welcome to work on new features.</li><li>I think Analog will be a big benefit to companies using Angular that want to use a headless CMS and provide their marketing department tools to update the website. I haven’t seen any examples yet of using Analog and a headless CMS but I’m sure they’ll come.</li></ul><p>I have really liked the experience of learning Analog so far, and am excited to learn more. The server routes are interesting, though I haven’t dove in to that yet, and there’s probably more with more to come. But it’s already at a good point right now. I’m not sure if the core team would recommend using it in production yet or not, but it seems stable at least for small projects.</p><h3>Contributing to Analog</h3><p>If there are some things you want to see Analog add, or if you find a bug, you should consider getting involved and contributing to the framework. Brandon is really patient and good at helping you contribute. And as with any open source project, the community will help drive it forward.</p><p>There are many types of contributions you can make. If you or your company can sponsor the project financially, that money will go a long way. If you can’t do that, use the framework and help the team work out any issues or bugs. Try and fix a bug, or submit enhanced documentation. There are a lot of ways that you can help, and they’re all appreciated.</p><h3>Conclusion</h3><p>In conclusion, re-writing my site in Analog has been a thoroughly pleasant experience. There is a lot of promise in the framework, and I’m excited to see where it goes. Make sure to follow <a href="https://twitter.com/brandontroberts">Brandon on Twitter</a>, or <a href="https://twitter.com/analogjs">Analog’s twitter account</a>. You can also join <a href="https://chat.analogjs.org/">the Discord community</a> and chat with others there.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8b93dbec680f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ngconf/analog-angulars-meta-framework-8b93dbec680f">Analog: Angular’s Meta Framework</a> was originally published in <a href="https://medium.com/ngconf">ngconf</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Angular Signals]]></title>
            <link>https://medium.com/ngconf/angular-signals-b47f849b1771?source=rss-39b42ea5b9d4------2</link>
            <guid isPermaLink="false">https://medium.com/p/b47f849b1771</guid>
            <category><![CDATA[angular-signals]]></category>
            <category><![CDATA[angular-16]]></category>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[signal]]></category>
            <dc:creator><![CDATA[Preston Lamb]]></dc:creator>
            <pubDate>Thu, 11 May 2023 17:11:52 GMT</pubDate>
            <atom:updated>2023-05-11T17:11:52.832Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Lx2-g4ZWe5LZANYU" /><figcaption>Photo by <a href="https://unsplash.com/@eliobedsuarez?utm_source=medium&amp;utm_medium=referral">Eliobed Suarez</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>tldr;</h3><p>For years now, Angular developers have been working with observables and state management libraries to make their applications reactive. Everyone has an opinion, and there have been a lot of different implementations. Recently, however, the Angular team released an official path forward for reactivity in Angular apps: Signals.</p><h3>What are Signals?</h3><p>According to the Angular docs, Angular Signals “is a system that granularly tracks how and where your state is used throughout an application, allowing the framework to optimize rendering updates.” In other words, it’s a way to manage state in the application in a way that allows Angular to react to changes in the most effective way possible. Effective use of signals will boost the performance of your application.</p><p>In essence, a signal is a wrapper around a value that allows consumers to be notified of changes to the value. The value inside a signal can be a simple primitive value, or a complex data structure. Because the value is always pulled from the signal via a getter, the framework always knows where the value is being used. Finally, signals can be either writable or read-only.</p><p>Signals are not unique to nor are they new with Angular. Similar implementations have been implemented in other frameworks. For example, SolidJS has been using signals for a while now, and the Angular team worked closely with the creator of Solid to figure out how best to implement signals in Angular.</p><h3>Why do we need Signals?</h3><p>When I first heard about the proposal for signals, I was confused as to why we needed them. Initially everyone was talking about their reactivity being one of the big draws. That was appealing, but I didn’t see the need since we already had Observables. Then I began to hear about the possibility that Signals would remove the need for using Zone.js in Angular apps in the future.</p><p>At a high level, Zone.js is a piece of the Angular framework that helps determine what parts of the app should be re-rendered and when. Zone.js and change detection are not always the most efficient of tasks. There are times where components may be re-rendered even though they don’t actually have any updates to display., Any improvements that can be made will be greatly beneficial, especially as apps grow in size.</p><p>Because Angular has a better idea of what parts of the application need updating when using Signals, updates to the application will be much more effective and efficient. As signals are adopted more in the future, the performance of Angular apps will be much better.</p><h3>Creating Your First Signal</h3><p>Alright, we have an idea now of what signals are and why we need them. Let’s now look into how we can create a signal and use it in an application. To create a signal, you need to import signal from @angular/core. Then you can create a variable like this:</p><pre>public name = signal(&#39;Preston&#39;);</pre><p>In this simple example, we have created a new signal and stored it in the name variable. We gave it an initial value of “Preston”. To display the value of the signal in the component, we use interpolation like normal, but you have to add parentheses to get the value from the signal:</p><pre>&lt;p&gt;{{ name() }}&lt;/p&gt;</pre><p>That wasn’t so bad, was it? But it will not be very often, if ever, that we create a signal and then never update the value of the signal. So how do we update it?</p><pre>public updateName(newName: string) {<br>  this.name.set(newName);<br>}</pre><p>When this method is called, the value of the signal is updated and the value output to the screen is updated as well. In a lot of ways, this simple example is really no different from using a normal variable and re-assigning the value. But in more complex situations and at a larger scale, this method is more performant.</p><h3>More Ways of Interacting with Signals</h3><p>Signals are more flexible and can do more than simply setting a new value. Let’s look at some of the other things you can do with signals.</p><h3>update</h3><p>The update method is another way to set a new value in the signal. The difference is that you can use the current value of the signal to derive the new value. Think about a situation where you’re keeping track of the number of times a button is clicked. Each time the button is clicked, we need to increment the value. We can do that like this:</p><pre>export class ButtonIncrementComponent {<br>  counter = signal(0);<br><br>  buttonClicked() {<br>    this.counter.update(current =&gt; current + 1;<br>  }<br>}</pre><p>Each time the button is clicked, the signal is updated by taking the current value and adding one to it.</p><h3>mutate</h3><p>The mutate method is similar to set or update, in that it changes the current value of the signal, but it does so by actually changing the value in place. In other words, you could update an attribute of an object in the signal without needing to pass in the entire object again.</p><pre>export class ItemDisplayComponent {<br>  public item = signal({ title: &#39;Item 1&#39;, completed: false });<br><br>  markAsCompleted() {<br>    this.item.mutate(item =&gt; item.completed = true);<br>  }<br>}</pre><p>In this example, an arrow function is passed as the parameter to the mutate method. This gives us access to the item in the signal, and allows us to alter the completed attribute in place. We didn’t need to pass in a completely new object to store in the signal.</p><h3>Computed Signals</h3><p>Some signals are special signals called computed signals. These signals are created based on the value of a different signal. An example of this might be in a shopping cart. You may have one signal that has the cost of the items in your cart, but you may want to display the amount of tax that the person owes as well. You can use a computed signal to calculate the value of the tax owed based on the total of the items in the cart. As the total is updated, the tax will automatically be updated as well.</p><pre>export class ShoppingCartComponent {<br>  public subtotal: WritableSignal&lt;number&gt; = signal(0);<br>  public tax: Signal&lt;number&gt; = computed(() =&gt; subtotal() * .07);<br>  <br>  addItemToCart(amount) {<br>    this.subtotal.update(tot =&gt; tot + amount);<br>  }<br>}</pre><p>In this example, our cart has a subtotal which is a WritableSignal that stores a number. There is also a tax signal that has a value based on the value of the subtotal. When we add an item to the cart, the subtotal is updated. The tax will automatically be updated as well, without the need of explicitly updating the value.</p><p>There are a couple interesting things to note about computed signals. The first is that they are not writable. They are read-only. Second is that the value is not computed until the first time the value which it relies upon is read. In this case, not until subtotal is read the first time. After the value is computed for tax the first time, its value is cached and stored for future reads. Its value will not be re-calculated again until the value of subtotal is changed. This is done automatically for all computed signals.</p><p>Computed values are extremely powerful and beneficial. The ability to update a value on the screen automatically when we update another signal is very convenient and has many use cases. I have come across many situations similar to the example listed above where computed signals would have been very convenient. In my opinion, this is one of the biggest reasons we have to be excited about signals.</p><h3>Effects</h3><p>Another piece of Angular Signals that has use cases, though few and far between, are effects. Effects are operations that are run when one or more signal value changes. Effects always run at least once, and always run asynchronously.</p><p>The official Angular docs say the following about effects:</p><blockquote><em>Effects are rarely needed in most application code, but may be useful in specific circumstances. Here are some examples of situations where an </em><em>[effect](&lt;https://angular.io/api/core/effect&gt;) might be a good solution:</em></blockquote><blockquote>- Logging data being displayed and when it changes, either for analytics or as a debugging tool<br>- Keeping data in sync with window.localStorage<br>- Adding custom DOM behavior that can’t be expressed with template syntax<br>- Performing custom rendering to a &lt;canvas&gt;, charting library, or other third party UI library</blockquote><p>Effects can be useful, but should be used with care. All the performance benefits of signals would be lost if you got yourself in an infinite loop.</p><h3>Conclusion</h3><p>Angular is moving forward at a rapid pace. Signals is just the latest example of that progress. The performance benefits and reactivity of signals is bound to permeate the community and apps in the coming months. While signals are still in developer preview, this is a good time to familiarize yourself with them and find use cases for them. In a future release, likely within the year (based on other features that went into developer preview), signals will exit developer preview and be ready to go officially.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b47f849b1771" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ngconf/angular-signals-b47f849b1771">Angular Signals</a> was originally published in <a href="https://medium.com/ngconf">ngconf</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>