<?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 Mateusz Salamon on Medium]]></title>
        <description><![CDATA[Stories by Mateusz Salamon on Medium]]></description>
        <link>https://medium.com/@matsal.dev?source=rss-274566d9a85a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*NmdBLeTwIKfOUxFTEP8e_Q.jpeg</url>
            <title>Stories by Mateusz Salamon on Medium</title>
            <link>https://medium.com/@matsal.dev?source=rss-274566d9a85a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 07:54:45 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@matsal.dev/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[Angular Signals Not Updating: How to Update Objects and Arrays]]></title>
            <link>https://medium.com/@matsal.dev/angular-signals-not-updating-how-to-update-objects-and-arrays-e35fbb2e2b50?source=rss-274566d9a85a------2</link>
            <guid isPermaLink="false">https://medium.com/p/e35fbb2e2b50</guid>
            <category><![CDATA[angular-signals]]></category>
            <category><![CDATA[angular]]></category>
            <dc:creator><![CDATA[Mateusz Salamon]]></dc:creator>
            <pubDate>Sun, 22 Nov 2026 00:01:05 GMT</pubDate>
            <atom:updated>2026-11-22T00:01:05.344Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YUGVj6lr8IUwM7wQRn5bMg.png" /></figure><p><em>Fix stale computed values when adding items, changing object properties, or editing an item inside an array.</em></p><p>You add an item to an array stored in an Angular signal. The array changes, but a computed count still shows the previous value.</p><p>This can happen even when you use update(). The important detail is what your update function returns.</p><p>Let’s reproduce the problem, then fix three common cases: updating an array, changing an object, and editing an object inside an array.</p><h3>Reproduce the problem</h3><p>Run this in an Angular TypeScript file. It uses the stable signal() and computed() APIs available since Angular 17.</p><pre>import { computed, signal } from &#39;@angular/core&#39;;<br>interface Item {<br>  id: number;<br>  title: string;<br>  done: boolean;<br>}<br><br>const items = signal&lt;Item[]&gt;([<br>  { id: 1, title: &#39;Review invoice&#39;, done: false },<br>]);<br>const itemCount = computed(() =&gt; items().length);<br><br>console.log(itemCount()); // 1: calculate and cache the count<br><br>items().push({ id: 2, title: &#39;Send reminder&#39;, done: false });<br><br>console.log(items().length); // 2<br>console.log(itemCount());    // 1</pre><p>The first read matters: computed() is lazy and caches its result. Here, the array was mutated after that result was cached.</p><p>The new item exists. The signal did not notify its consumers of a change.</p><h3>Why mutation does not notify the signal</h3><p>items() gives you the current array. Calling push() changes that array directly and never calls the signal&#39;s write API.</p><p>When you do call set() or update(), Angular compares the previous and next values. By default, the comparison uses Object.is(). For objects and arrays, the same reference compares equal.</p><pre>const previous = items();<br>const sameArray = previous;<br>const newArray = [...previous];<br><br>Object.is(previous, sameArray); // true<br>Object.is(previous, newArray);  // false</pre><p>Now the fixes become predictable.</p><h3>1. Add or remove array items with a new array</h3><p>Replace a direct mutation:</p><pre>// Avoid: changes the array without a signal write<br>items().push(newItem);</pre><p>with an update that returns a new array:</p><pre>function addItem(newItem: Item): void {<br>  items.update(current =&gt; [...current, newItem]);<br>}<br><br>function removeItem(id: number): void {<br>  items.update(current =&gt; current.filter(item =&gt; item.id !== id));<br>}</pre><p>Use update() when the next value depends on the current value. If you already have a complete replacement, use set():</p><pre>const loadedItems: Item[] = [<br>  { id: 3, title: &#39;Approve payment&#39;, done: false },<br>];<br>items.set(loadedItems);</pre><p>Both methods use the signal’s equality check. Calling either method with the existing reference does not turn a mutation into a reactive update.</p><h3>2. Change an object by replacing its container</h3><p>The same rule applies to an object property:</p><pre>const user = signal({ name: &#39;Alice&#39;, city: &#39;Warsaw&#39; });<br><br>// Avoid: direct property mutation<br>user().name = &#39;Bob&#39;;<br>// Prefer: a new object with the changed property<br>user.update(current =&gt; ({ ...current, name: &#39;Bob&#39; }));</pre><p>For a nested property, copy the changed object and its containers:</p><pre>const invoice = signal({<br>  id: &#39;INV-42&#39;,<br>  customer: { name: &#39;Alice&#39;, city: &#39;Warsaw&#39; },<br>})<br>invoice.update(current =&gt; ({<br>  ...current,<br>  customer: { ...current.customer, city: &#39;Gdansk&#39; },<br>}));</pre><p>This is a shallow copy at each changed level. You do not need to deep-clone unrelated parts of your state.</p><h3>3. Edit an object inside an array</h3><p>A common example is marking one item as done:</p><pre>// Avoid: changes an object inside the existing array<br>items()[0].done = true;</pre><p>Return a new array and a new object for the edited item:</p><pre>function markDone(id: number): void {<br>  items.update(current =&gt;<br>    current.map(item =&gt;<br>      item.id === id ? { ...item, done: true } : item<br>    )<br>  );<br>}</pre><p>The other items keep their references. This also preserves a useful boundary when an item is passed to an OnPush child component: the edited child receives a new object input.</p><p>Copying only the array after mutating an item can notify array consumers, but leaves that item’s identity unchanged. A child receiving the same object input may stay stale unless another trigger causes it to be checked.</p><h3>Why update() alone does not fix it</h3><p>This still returns the original array:</p><pre>items.update(current =&gt; {<br>  current.push({ id: 4, title: &#39;Export report&#39;, done: false });<br>  return current;<br>});</pre><p>update() computes a next value and passes it through the write path; it does not automatically clone its argument. The default equality check still sees the same reference.</p><p><em>Direct mutation bypasses the write path. A custom equality function can also consider two different references equal.</em></p><h3>Two safeguards worth knowing</h3><p>asReadonly() hides set() and update() from consumers. It does not freeze the stored array or its objects. For compile-time protection, use readonly types for both levels:</p><pre>type ReadonlyItem = Readonly&lt;Item&gt;;<br><br>const safeItems = signal&lt;readonly ReadonlyItem[]&gt;([]);<br>// TypeScript errors:<br>// safeItems().push({ id: 1, title: &#39;Review&#39;, done: false });<br>// safeItems()[0].done = true;<br>// Valid: produce a replacement<br>safeItems.update(current =&gt; [<br>  ...current,<br>  { id: 1, title: &#39;Review&#39;, done: false },<br>]);</pre><p>These types do not freeze values at runtime. Deeper structures need readonly types at their own levels.</p><p>Also check whether your signal uses a custom equal function. A new reference can still compare equal under that rule.</p><h3>Takeaway</h3><p>When an object or array signal appears stuck, check the write before reaching for change detection workarounds:</p><ul><li>Use set() or update() instead of mutating the value returned by the signal.</li><li>Return a new container for changed state.</li><li>Replace edited objects inside arrays; keep unchanged objects as they are.</li><li>Check a custom equality function if a new reference still produces no notification.</li></ul><p>That fixes the state flow and makes the update understandable to both Angular and the next developer reading your code.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e35fbb2e2b50" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ViewEncapsulation in Angular: Emulated, None, ShadowDOM]]></title>
            <link>https://medium.com/@matsal.dev/viewencapsulation-in-angular-emulated-none-shadowdom-639c42d116c1?source=rss-274566d9a85a------2</link>
            <guid isPermaLink="false">https://medium.com/p/639c42d116c1</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[shadow-dom]]></category>
            <category><![CDATA[view-encapsulation]]></category>
            <category><![CDATA[typescript]]></category>
            <dc:creator><![CDATA[Mateusz Salamon]]></dc:creator>
            <pubDate>Fri, 27 May 2022 18:55:48 GMT</pubDate>
            <atom:updated>2022-05-27T18:55:48.704Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/887/1*7AniKP1elMuY3mkPYz1bwA.png" /></figure><p>Many of us in our work have come across the concept of encapsulation. It applies not only to issues related to object-oriented programming but in the case of Angular it also applies to views. In this article, I will try to briefly present the most important information about the types of views encapsulation.</p><h3>Introduction</h3><p>You can easily set the encapsulation type by specifying it in the “encapsulation” property of the @Component decorator:</p><pre>@Component({<br>  selector: &#39;app-root&#39;,<br>  template: `&lt;h1&gt;Example&lt;/h1&gt;`,<br>  encapsulation: ViewEncapsulation.Emulated,<br>  // or ViewEncapsulation.None or ViewEncapsulation.ShadowDom<br>})</pre><h3>ViewEncapsulation.Emulated</h3><ul><li>set by default,</li><li>styles added in the document’s &lt;head&gt;&lt;/head&gt;, but with “scoped” styles,</li><li>styles that are available throughout the application, but their selectors only affect the view of a specific component.</li></ul><pre>import { Component, ViewEncapsulation } from &quot;@angular/core&quot;;<br>@Component({<br>  selector: &#39;app-emulated-card&#39;,<br>  template: `<br>    &lt;div class=&quot;container&quot;&gt;<br>      &lt;p&gt;Card with ViewEncapsulation.Emulated&lt;/p&gt;<br>    &lt;/div&gt;<br>`,<br>  styles: [&#39;<br>    .container { <br>      background:#F0EFEF;<br>      padding: 20px ;<br>      border-radius: 15px; <br>      margin: 15px;<br>     }<br>  &#39;],<br>  encapsulation: ViewEncapsulation.Emulated,<br>})<br>export class EmulatedCardComponent { }</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/492/1*JmHm_7Fn_EgwZdHQfdL9Rw.png" /></figure><h3>ViewEncapsulation.None</h3><ul><li>styles added to the document’s &lt;head&gt; &lt;head&gt;,</li><li>styles available throughout the app,</li><li>their selectors affect all matching elements throughout the document,</li><li>the parent component may override the styles of the child component that has ViewEncapsulation.None.</li></ul><pre>import { Component, ViewEncapsulation } from &quot;@angular/core&quot;;</pre><pre>@Component({<br>  selector: &#39;app-no-card&#39;,<br>  template: `<br>    &lt;div class=&quot;container&quot;&gt;<br>      &lt;p&gt;Card with ViewEncapsulation.None&lt;/p&gt;<br>    &lt;/div&gt;<br>  `,<br>  styles: [&#39;<br>    .container { <br>      background: #DFDFDF; <br>      padding: 20px;<br>      margin: 15px; <br>      border-radius: 15px;<br>    }<br>  &#39;],<br>  encapsulation: ViewEncapsulation.None<br>})</pre><pre>export class NoCardComponent { }</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/499/1*PhqcS8cutDSsgZZp2-TsAQ.png" /></figure><h3>ShadowDOM</h3><p>This type of encapsulation may be puzzling to some, because… what exactly is shadowDOM? Admittedly, the documentation covers this point extensively, which could be summarized in <a href="https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_shadow_DOM">these words</a>:</p><blockquote>Shadow DOM allows hidden DOM trees to be attached to elements in the regular DOM tree — this shadow DOM tree starts with a shadow root, underneath which can be attached to any elements you want, in the same way as the normal DOM.</blockquote><p>However, such a sentence may not tell us much. I think that this example describes how the shadowDOM works in better way:<br>Let’s imagine that we put a &lt;video&gt; tag on our application:</p><pre>&lt;div&gt;<br>  &lt;video&gt;&lt;video&gt;<br>&lt;/div&gt;</pre><p>If we look at the DOM tree, we will see this view in the inspector:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/305/1*a9A2HdqntX49k7-xGCnyNA.png" /></figure><p>However, when we enable the “shadowDOM” preview in the browser, we will see the following tree:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/350/1*HMJPe_1Roc8K_hUshvhKBA.png" /></figure><p>Elements inside the &lt;video&gt; tag are not inserted into the code by the developer but are hidden from the developer. The browser that renders these child elements inside the parent element. The &lt;video&gt; element is converted into the DOM tree as shown above. This is what “shadowDOM” is all about.</p><h3>ViewEncapsulation.ShadowDOM</h3><ul><li>styles added to the shadowDOM host,</li><li>they only affect entities in the views of the corresponding components,</li><li>affect the view of components with set encapsulation on ViewEncapsulation.None</li></ul><pre>import { Component, ViewEncapsulation } from &quot;@angular/core&quot;;</pre><pre>@Component({<br>  selector: &#39;app-shadow-card&#39;,<br>  template: `<br>    &lt;div class=&quot;container&quot;&gt;<br>      &lt;p&gt;Card with ViewEncapsulation.ShadowDom&lt;/p&gt;<br>    &lt;/div&gt;<br>  `,<br>  styles: [&#39;<br>    p {<br>      color: black;<br>    }<br>    .container { <br>      box-shadow: grey;<br>      padding: 20px;<br>      border-radius: 15px;}<br>  &#39;],<br>  encapsulation: ViewEncapsulation.ShadowDom,<br>})</pre><pre>export class ShadowCardComponent { }</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/494/1*x5VlXtbZN0LXs4kOWdK0KQ.png" /></figure><h3>All views</h3><p>Now let’s check all the components together by declaring them in the app.component.html:</p><pre>&lt;app-none-card&gt;&lt;/app-none-card&gt;<br>&lt;app-emulated-card&gt;&lt;/app-emulated-card&gt;<br>&lt;app-shadow-card&gt;&lt;/app-shadow-card&gt;</pre><p>We got the following view:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*aYVR41Wyc3cXh-4Cx9o36w.png" /></figure><p>But if we add cards with encapsulation “None”and “Emulated” to the card with encapsulation “shadowDOM”:</p><pre>@Component({<br>  selector: &#39;app-shadow-card&#39;,<br>  template: `<br>    &lt;div class=&quot;container&quot;&gt;<br>      &lt;p&gt;Card with ViewEncapsulation.ShadowDom&lt;/p&gt;<br>      &lt;app-none-card&gt;&lt;/app-none-card&gt;<br>      &lt;app-emulated-card&gt;&lt;/app-emulated-card&gt;<br>    &lt;/div&gt;<br>  `,<br>  styles: // styles here<br>  encapsulation: ViewEncapsulation.ShadowDom,<br>})</pre><p>we can notice that the background color from the card with “shadowDOM” affected a card with the “None” encapsulation, but did not affect a card with the “Emulated” encapsulation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/503/1*bwBB28g_05kj12UC505pbg.png" /></figure><h3>Summary</h3><p>View encapsulation is a rarely used tool, although very useful in some cases. However, avoid mixing styles in the application. It can cause undesirable overwriting of CSS style classes, resulting in an unexpected appearance of the application. If you would like to get more information, I recommend reading <a href="https://angular.io/guide/view-encapsulation">the documentation</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=639c42d116c1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Angular: Difference between Observables and Promises in a nutshell]]></title>
            <link>https://medium.com/@matsal.dev/angular-difference-between-observables-and-promises-in-a-nutshell-2a79617029a7?source=rss-274566d9a85a------2</link>
            <guid isPermaLink="false">https://medium.com/p/2a79617029a7</guid>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[observables]]></category>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Mateusz Salamon]]></dc:creator>
            <pubDate>Tue, 24 May 2022 19:39:06 GMT</pubDate>
            <atom:updated>2022-05-24T19:39:06.216Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/848/1*axxsmkL8ZJVidmz9oUPbkQ.png" /></figure><p>If you’ve ever used the Angular framework to build web applications, you’ve probably noticed that it has a built-in RxJS library that enables reactive programming. It allows us to use Observables to handle asynchronous requests, instead of Promises. Of course, we can also use the second method, but what’s the difference? In this article, I will try to answer this question.</p><h3>Promise:</h3><ul><li>return only a single value,</li><li>execute immediately,</li><li>not cancellable (possible two solutions: reject() or resolve()),</li><li>always asynchronous,</li><li>support for async, await,</li><li>doesn’t support operators,</li><li>support one listener,</li><li>use then() to handle the request,</li><li>push errors to child promises,</li><li>use when you have a single async operation.</li></ul><h3>Observables:</h3><ul><li>return stream of data,</li><li>lazy — not executed until the consumer subscribes,</li><li>can be canceled using unsubscribe(),</li><li>can be asynchronous and synchronous,</li><li>provides different operators which can combine in the chain,</li><li>supports many listeners,</li><li>use subscribe to handle the request,</li><li>errors are delivered to the subscriber’s error handler,</li><li>use next() to emit value to the observer, error() to inform about the error, and void function to inform about stream completion,</li><li>use to handle user events, like click, or if you work with WebSockets.</li></ul><h3>Summary</h3><p>I hope this short comparison helped you understand the differences between the two ways of dealing with asynchronous tasks. If you want to know more, I encourage you to check out the <a href="https://angular.io/guide/comparing-observables">official documentation </a>and the discussion on <a href="https://stackoverflow.com/questions/37364973/what-is-the-difference-between-promises-and-observables">StackOverflow</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2a79617029a7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Angular: How to access the component inside <ng-content> using @ContentChild]]></title>
            <link>https://medium.com/@matsal.dev/angular-how-to-access-the-component-inside-ng-content-using-contentchild-2e88b455b6c2?source=rss-274566d9a85a------2</link>
            <guid isPermaLink="false">https://medium.com/p/2e88b455b6c2</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[software-engineering]]></category>
            <dc:creator><![CDATA[Mateusz Salamon]]></dc:creator>
            <pubDate>Mon, 23 May 2022 14:20:39 GMT</pubDate>
            <atom:updated>2023-02-17T22:11:02.583Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/738/1*iQfoahFsq1kJ9VVefEcjHw.png" /></figure><p>When creating components in Angular, sometimes we want to put one component inside another. To do this, we can either declare a component in another component’s template or use the content projection and place the component inside the tags of another component. In this article, I will show you how a parent component can get to the properties of a component placed using content projection.</p><h3>1. Create a new project</h3><p>First, let’s create a new project. If you don’t know how to do it, I recommend my article where you can find instructions on <a href="https://medium.com/@matsal.dev/angular-creating-new-project-214a5b542338">how to create a new project in Angular</a>.</p><h3>2. Create a CarDescriptionComponent</h3><p>Let’s create a CarDescription component using the command below:</p><pre>ng g c car-description</pre><p>In this component, we will declare two variables: “description”, which will store the car’s description, and “price”, which will store its price. The component code is below:</p><pre>import { Component } from &#39;@angular/core&#39;;</pre><pre>@Component({<br>  selector: &#39;app-car-description&#39;,<br>  template: `&lt;p&gt;{{description}}&lt;/p&gt;`,<br>  styleUrls: [&#39;./car-description.component.css&#39;]<br>})<br>export class CarDescriptionComponent {</pre><pre>  description: string = &#39;This car will provide you with an amazing experience, and its performance will ensure that you will never want to drive anything else.&#39;;</pre><pre>  price: number = 10000;<br>}</pre><h3>3. Create a CarComponent</h3><p>Now, let’s create a CarComponent using the command below:</p><pre>ng g c car</pre><p>Then put the code below:</p><pre>import { ContentChild } from &#39;@angular/core&#39;;<br>import { AfterViewInit } from &#39;@angular/core&#39;;<br>import { Component } from &#39;@angular/core&#39;;<br>import { CarDescriptionComponent } from &#39;../car-description/car-description.component&#39;;</pre><pre>@Component({<br>  selector: &#39;app-car&#39;,<br>  template: `&lt;h1&gt;Ford Mustang&lt;/h1&gt;<br>    &lt;ng-content select=&quot;[description]&quot;&gt;&lt;/ng-content&gt;`,<br>  styleUrls: [&#39;./car.component.css&#39;]<br>})<br>export class CarComponent implements AfterViewInit { }</pre><p>In this component, we have placed the &lt;ng-content&gt; tag, thanks to which it will be possible to project the content. The content will be displayed only if the component we want to put inside will be marked with the “description” directive. This condition is specified in the “select” directive.</p><h3>4. Show components</h3><p>To see how our simple application works, paste the code below in the app.component.html file:</p><pre>&lt;app-car&gt;<br>  &lt;app-car-description&gt;&lt;/app-car-description&gt;<br>&lt;/app-car&gt;</pre><p>The app-car-description component will be placed inside &lt;ng-content&gt; tags in CarComponent thanks to the “description” directive. After launching, we should get this view:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/870/0*YXu9dVh7XmoYmAio" /></figure><h3>5. Use @ContentChild</h3><p>If we want to not only display the component but also get to its variables, the @ContentChild attribute comes in handy, which allows you to get to the variables contained in the component placed inside &lt;ng-content&gt;. In the car.component.ts file, put the following code:</p><pre>export class CarComponent implements AfterViewInit {</pre><pre>@ContentChild(CarDescriptionComponent) carDescription: CarDescriptionComponent</pre><pre>ngAfterViewInit() {<br>  console.log(this.carDescription);<br>  const price = this.carDescription.price;<br>  console.log(&#39;price from carDescription: &#39;, price);<br>}</pre><p>When we open the browser console, we should see this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/546/0*PuFDaC6OwJptbCui" /></figure><p>As you can see, thanks to the @ContentChild decorator, we got access to the variables inside the CarDescriptionComponent. When using @ContentChild it is important to get to the component after its initialization — for this, I used the “ngAfterViewInit()” hook. If we reference this component before initializing it, for example using “ngOnInit()”, we get “undefined”. If we want to get access to the component within “ngOnInit()”, we should use “static: true” as below:</p><pre>@ContentChild(CarDescriptionComponent, { static: true}) carDescription: CarDescriptionComponent</pre><h3>Summary</h3><p>Thanks to the @ContentChild attribute, we can get to the variables in the component that we want to put inside &lt;ng-content&gt;. However, remember to use the correct Hook.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2e88b455b6c2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Angular: Difference between Reactive Form and Template-Driven Form in a nutshell]]></title>
            <link>https://medium.com/@matsal.dev/angular-difference-between-reactive-form-and-template-driven-form-in-a-nutshell-5ad3339dc5?source=rss-274566d9a85a------2</link>
            <guid isPermaLink="false">https://medium.com/p/5ad3339dc5</guid>
            <category><![CDATA[template-driven-form]]></category>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[reactive-forms]]></category>
            <category><![CDATA[typescript]]></category>
            <dc:creator><![CDATA[Mateusz Salamon]]></dc:creator>
            <pubDate>Wed, 18 May 2022 21:04:09 GMT</pubDate>
            <atom:updated>2022-05-18T21:04:09.257Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/798/1*IPv5h63gXcO-n8KR34g03A.png" /></figure><p>Forms are an essential part of almost all web applications. Angular offers us two different approaches to creating them: template-based forms and reactive forms. In this article, I will provide a brief comparison of both ways.</p><h3>Features</h3><h4>Reactive Form:</h4><ul><li>more scalable,</li><li>based on structured and immutable data model,</li><li>use asynchronous data flow between the view and the data model,</li><li>data validation is done by a function that receives a control to validate,</li><li>the form model is the source of truth,</li><li>easier to test.</li></ul><h4>Template-Driven Form</h4><ul><li>less scalable,</li><li>based on an unstructured and mutated data model,</li><li>use asynchronous data flow between the view and the data model,</li><li>validation is done using directives,</li><li>the source of truth is the template,</li><li>more difficult to test due to the required knowledge of the operation of the change detection mechanism,</li><li>use the directive [(ngModel)],</li></ul><h3>How to use:</h3><p><strong>Reactive Form:</strong></p><pre>@Component({<br>  selector: &#39;app-simple-form&#39;,<br>  template: `<br>    &lt;input type=&quot;text&quot; placeholder=”Fill your name”<br>[formControl]=&quot;name&quot;&gt;`<br>})<br>export class SimpleFormComponent {<br>  name = new FormControl(&#39;&#39;);<br>}</pre><p>To use this approach, first import <strong>ReactiveFormsModule</strong> to your module.</p><p><strong>Template-Driven Form:</strong></p><pre>@Component({<br>  selector: &#39;app-simple-template-form&#39;,<br>  template: `&lt;input type=&quot;text&quot; placeholder=”Fill your name”<br>    [(ngModel)]=&quot;name&quot;&gt;`<br>})<br>export class SimpleTemplateFormComponent {<br>  name: string = ‘’;<br>}</pre><p>To use this approach, first import <strong>FormsModule</strong> to your module.</p><h3>When to use:</h3><p><strong>Reactive Form:</strong></p><ul><li>extensive forms that can be divided into sections containing many fields,</li><li>dynamic forms (the number of fields varies).</li></ul><p><strong>Template-Driven Form:</strong></p><ul><li>simple forms with a small number of fields (from 1 to 3).</li></ul><h3>Conclusion</h3><p>The decision to choose the type of form is usually made based on the number of fields, but as a programmer, you have full freedom and you can use whatever method you think is best for your application. If you want to deepen your knowledge of the forms, please visit the <a href="https://angular.io/guide/forms-overview">documentation page</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5ad3339dc5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Angular: ChangeDetectionStrategy OnPush in a nutshell]]></title>
            <link>https://medium.com/@matsal.dev/angular-changedetectionstrategy-onpush-in-a-nutshell-b1bd8aaeea64?source=rss-274566d9a85a------2</link>
            <guid isPermaLink="false">https://medium.com/p/b1bd8aaeea64</guid>
            <category><![CDATA[change-detection]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[angular]]></category>
            <dc:creator><![CDATA[Mateusz Salamon]]></dc:creator>
            <pubDate>Mon, 16 May 2022 23:46:56 GMT</pubDate>
            <atom:updated>2022-05-16T23:46:56.673Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/957/1*nIeelqaTVoNuOBRLs3ajFg.png" /></figure><p>The mechanism of detecting changes in Angular plays a fundamental role in comparing the previous state of the application with the current one. There are two possible strategies that determine when change detection can occur “Default” and “OnPush”. In this article, I will introduce you to the second strategy: “onPush”.</p><h3>How it works:</h3><h4>Default strategy:</h4><ul><li>With each change in the state of the application, e.g. clicking on a button, or typing something into input, the change detection mechanism is triggered</li><li>This mechanism looks for changes in each component and compares the previous state of the application with the current one, e.g. before clicking the button, the counter variable was 1, and after clicking it increased to 2</li><li>When a change is detected, the component is updated.</li></ul><h4>OnPush startegy:</h4><ul><li>the difference is that this change detection strategy does not look for changes in all components, but skips components and their children marked “onPush”, which is much faster. This is shown in the graphic below:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/821/0*uYHCm-52LW4fY1Ak" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/823/0*lp_snVyAlcA8jGmf" /></figure><p>As you can see, with “onPush”, checks fewer components, which speeds up the application.</p><h3>When it doesn’t work</h3><p>OnPush strategy doesn’t trigger change detection if we use an asynchronous function like:</p><ul><li>setInterval,</li><li>setTimeout,</li><li>Promise resolve and reject</li><li>RxJS subscriptions</li></ul><h3>Why use:</h3><ul><li>Reduce change detection time.</li><li>Improve performance of the application (the app’s view works “smoother”).</li><li>It is more efficient, so it can even reduce battery consumption on mobile devices.</li></ul><h3>How to use:</h3><p>To use the “onPush” strategy, just set the value of the “changeDetection” property to “ChangeDetectionStrategy.OnPush”:</p><pre>@Component({<br>  selector: &#39;app-parent-component’,<br>  templateUrl: &#39;./app.parent.component.html&#39;<br>  changeDetection: ChangeDetectionStrategy.OnPush<br>})</pre><h3>Default configuration:</h3><p>If we want to use the “onPush” strategy by default, we can add the “changeDetection” property to the angular.json file and set it to “onPush”:</p><pre>&quot;schematics&quot;: {<br>  &quot;@schematics/angular:component&quot;: {<br>    &quot;changeDetection&quot;: &quot;OnPush&quot;,<br>    &quot;style&quot;: &quot;scss&quot;<br>   }<br>   …<br>}</pre><h3>When to use:</h3><ul><li>In components that have @Input decorators and take value from parent-component. In this case change detection “onPush” starts detection only if its input property changes.</li><li>In big projects to optimize the change detection process which is a very expensive operation.</li><li>Using in components immutable objects as @Input property (change reference, not value).</li></ul><h3>Summary</h3><p>As you can see, the “onPush” strategy can turn out to be very useful in optimizing the process of detecting changes and, consequently, faster operation of the application. However, be careful when using this strategy as it doesn’t work very well in some cases. If you want to deepen your knowledge, I encourage you to read these articles:</p><ul><li><a href="https://mokkapps.de/blog/the-last-guide-for-angular-change-detection-you-will-ever-need/">https://mokkapps.de/blog/the-last-guide-for-angular-change-detection-you-will-ever-need/</a></li><li><a href="https://www.thinktecture.com/en/angular/whats-the-hype-onpush/">https://www.thinktecture.com/en/angular/whats-the-hype-onpush/</a></li><li><a href="https://blog.angular-university.io/onpush-change-detection-how-it-works/">https://blog.angular-university.io/onpush-change-detection-how-it-works/</a></li></ul><p>or follow this discussion:</p><p><a href="https://stackoverflow.com/questions/52979543/should-i-always-use-changedetectionstrategy-onpush">https://stackoverflow.com/questions/52979543/should-i-always-use-changedetectionstrategy-onpush</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b1bd8aaeea64" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Angular: useValue, useClass, useExisting and useFactory in a nutshell]]></title>
            <link>https://medium.com/@matsal.dev/angular-usevalue-useclass-useexisting-and-usefactory-in-a-nutshell-97db8d206084?source=rss-274566d9a85a------2</link>
            <guid isPermaLink="false">https://medium.com/p/97db8d206084</guid>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[typescript]]></category>
            <dc:creator><![CDATA[Mateusz Salamon]]></dc:creator>
            <pubDate>Sun, 15 May 2022 21:11:05 GMT</pubDate>
            <atom:updated>2024-11-14T21:48:06.579Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/672/1*KtFBN0SIPRsAWB77V5LKGw.png" /></figure><p>The dependency injection mechanism in Angular allows us to configure dependency providers in several different ways. Thanks to them, we can determine how the dependencies will be provided to our classes. In this article I will try to explain 4 different ways of creating dependencies: useValue, useFactory, useClass and useExisting.</p><h3>useValue</h3><ul><li>Lets you inject a value or a function.</li><li>Often used to set the initial configuration.</li></ul><pre>export const RACE_CARS_CONFIG: CARS_CONFIG= {<br>  domain: &#39;api.race-cars.com&#39;,<br>};</pre><pre>providers: [CarsService,<br> { provide: CARS_CONFIG, useValue: RACE_CARS_CONFIG}<br>]</pre><h3>useClass</h3><ul><li>Returns another class, specified by “useClass” when component asks for class specified in “provide”.</li><li>It is useful, for example, when unit testing components. We don’t have to provide the full service then, but we can create a separate class that will be able to implement the methods in a different way. Thanks to this, we will only test the component itself and not its interaction with the service.</li></ul><pre>providers: [{ provide: UserService, useClass: mockUserService}]</pre><p>In case the provide and useClass values are the same</p><pre>providers: [{ provide: UserService, useClass: UserService}]</pre><p>we can use a shorter write</p><pre>providers: [UserService]</pre><h3>useExisting</h3><ul><li>Creates two ways to access the same service object with two different tokens.</li><li>It works well, e.g. when we have many methods on the service, and we only want to use a few of them. This helps in reducing the size of the interface.</li></ul><p>Sample service:</p><pre>class CarService {<br>  getWeight(): number {...}<br>  getColor(): string {...}<br>  getName(): string {...}<br>  getWidth(): number {...}<br>  getHeight(): number { … }<br>  getModel(): string {...}<br>  getYear(): number {...}<br>  ...<br>}</pre><p>Reduced implementation:</p><pre>export abstract class CarSizeService {<br>  abstract getHeight: number;<br>  abstract getWidth: number;<br>}</pre><p>Providers array:</p><pre>providers: [{ provide: CarSizeService, useExisting: CarService}]</pre><h3>useFactory</h3><ul><li>Specifies the function that is called and injects its return value.</li><li>It is useful when we want to get some value from the information which is not available before the run application, e.g. load some data from another page.</li><li>If it has dependencies, put them in the dependencies array.</li><li>It may include a “multi” property that allows multiple providers spread across many files to provide configuration information to a common token.</li></ul><p>Function implementation:</p><pre>function configUrlFactory (configUrl: ConfigUrlService) { return () =&gt; configUrl.load(); }</pre><p>Providers array:</p><pre>providers: [{<br>  provide: APP_INIT,<br>  useFactory: configUrlFactory,<br>  deps: [ConfigUrlService],<br>  multi: true<br>}]</pre><p>Example service:</p><pre>@Injectable() export class ConfigUrlService{<br>constructor(private http: HttpClient){}<br>  load(): Promise&lt;any&gt; {<br>    return http.get(‘https://exampleConfigUrl.com’).toPromise();<br>  }<br>}</pre><h3>Conclusion</h3><p>As you can see, by creating dependencies in different ways, we can get a whole range of different solutions to our problems.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=97db8d206084" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Angular: Difference between pure and impure pipe in a nutshell]]></title>
            <link>https://medium.com/@matsal.dev/angular-difference-between-pure-and-impure-pipe-in-a-nutshell-c9f389cab83a?source=rss-274566d9a85a------2</link>
            <guid isPermaLink="false">https://medium.com/p/c9f389cab83a</guid>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[typescript]]></category>
            <dc:creator><![CDATA[Mateusz Salamon]]></dc:creator>
            <pubDate>Fri, 13 May 2022 22:47:49 GMT</pubDate>
            <atom:updated>2022-05-13T22:47:49.154Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/796/1*suzgCSdXSHwEooCNY5ckeg.png" /></figure><p>In this article, I will present you briefly what is the difference between a pure pipe and impure one.</p><h3>Pure Pipe</h3><ul><li>good for transformation primitive input values like String, Number, Boolean or object reference like Date,</li><li>bad for the transformation of a complex object</li><li>it doesn’t detect changes when changing the length of the array</li><li>executes whenever it detects a change for the input or reference</li><li>does not work when mutating data in an array</li></ul><h4>Example</h4><p>In this example, you can see the student list being filtered through the UniversityPipe:</p><p>App.component.html:</p><pre>&lt;input placeholder=&quot;name&quot; #name&gt;<br>&lt;input placeholder=&quot;university&quot; #university&gt;<br>&lt;button (click)=&quot;add(name.value, university.value)&quot;&gt;Add student&lt;/button&gt;<br>&lt;div&gt;  <br>  &lt;table&gt;    <br>    &lt;th&gt;Name University&lt;/th&gt;    <br>    &lt;tr *ngFor=&quot;let student of (students | university)&quot;&gt;<br>      &lt;td&gt;{{student.name}}&lt;/td&gt;<br>      &lt;td&gt;{{student.university}}&lt;/td&gt;   <br>    &lt;/tr&gt;  <br>  &lt;/table&gt;<br>&lt;/div&gt;</pre><p>App.component.ts:</p><pre>@Component({<br>  selector: &#39;app-root&#39;,<br>  templateUrl: &#39;./app.component.html&#39;,<br>  styleUrls: [&#39;./app.component.scss&#39;]<br>})<br>export class AppComponent {</pre><pre>@ViewChild(&#39;name&#39;) name: ElementRef;<br>@ViewChild(&#39;university&#39;) university: ElementRef;</pre><pre>students = [<br>    { name: &#39;John&#39;, university: &#39;University of Chicago&#39; },<br>    { name: &#39;Ann&#39;, university: &#39;University of Pensylwania&#39; },<br>    { name: &#39;Sarah&#39;, university: &#39;University of Pensylwania&#39;},<br>    { name: &#39;Mike&#39;, university: &#39;Yale University&#39; },<br>    { name: &#39;Kevin&#39;, university: &#39;Yale University&#39;},<br>    { name: &#39;Jack&#39;, university: &#39;Yale University&#39; }<br>  ]</pre><pre>add(name: string, university: string) {<br>  this.students.push({name, university});<br>  this.name.nativeElement.value = &#39;&#39;;<br>  this.university.nativeElement.value = &#39;&#39;;<br>}</pre><p>UniversityPipe.ts:</p><pre>import { Pipe, PipeTransform } from &#39;@angular/core&#39;;<br>import { Student } from &#39;./student&#39;;</pre><pre>@Pipe({<br>  name: &#39;university&#39;,<br>})<br>export class UniversityPipe implements PipeTransform {<br>  transform(students: Student[]): Student[] {<br>    return students.filter((student) =&gt; student.university ===<br>&#39;University of Pensylwania&#39;);<br>  }<br>}</pre><p>This pipe works if the array length is still the same. If we add a new student to our list, the pipe won’t work.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*WcRZ-b14qzoYLDvYGe3I9w.gif" /></figure><h3>Impure pipe</h3><ul><li>good for use with complex objects</li><li>detects changes when the length of an array is changed, such as when added or deleted</li><li>detects differences in nested objects</li><li>detects changes with each change, e.g. button clicks</li><li>slows down the performance of the application</li></ul><p>If we add a value ‘false’ to property ‘pure’ we obtain an impure pipe:</p><pre>@Pipe({<br>  name: &#39;university&#39;,<br>  pure: false<br>})</pre><p>Now, when we add a new student to the board, our list will update.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*za0E27rgIQZjP_AGvlUi8A.gif" /></figure><h3>Summary</h3><p>Pipes are a tool that should be used with care. Works great for transforming simple types (pure), but can also be used for filtering (impure). However, it should be remembered that the use of impure pipes may slow down the application.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c9f389cab83a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Angular: How two-way binding works with [(ngModel)]]]></title>
            <link>https://medium.com/@matsal.dev/angular-how-two-way-binding-works-with-ngmodel-19c5e6ebe268?source=rss-274566d9a85a------2</link>
            <guid isPermaLink="false">https://medium.com/p/19c5e6ebe268</guid>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[data-binding-in-angular]]></category>
            <category><![CDATA[angular]]></category>
            <dc:creator><![CDATA[Mateusz Salamon]]></dc:creator>
            <pubDate>Wed, 11 May 2022 19:41:15 GMT</pubDate>
            <atom:updated>2022-05-11T19:41:15.376Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1017/1*xLIbDOh-rCgGnnaqSrSr-g.png" /></figure><p>In this article, I will show you some simple examples of how two-way binding works.</p><h3>Property binding</h3><p>The name “Two-way data binding” says that the data flow is in two different ways. The first is the flow from source to view.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/811/1*g_FIUPgdkT7otC122MCFeA.png" /></figure><p>This could be, for example, displaying a variable from a component in the {{interpolation}} view of our template as shown below:</p><pre>import { Component } from &#39;@angular/core&#39;;</pre><pre>@Component({<br>  selector: &#39;app-root&#39;,<br>  template: `&lt;div&gt;{{counter}}&lt;/div&gt;`,<br>})</pre><pre>export class AppComponent {<br>  counter: number = 4;<br>}</pre><p>Or assigning a counter value to the “value” attribute:</p><pre>import { Component } from &#39;@angular/core&#39;;</pre><pre>@Component({<br>  selector: &#39;app-root&#39;,<br>  template: `&lt;input type=&quot;number&quot; [value]=&quot;counter&quot;&gt;`,<br>})</pre><pre>export class AppComponent {<br>  counter: number = 4;<br>}</pre><h3>Event binding</h3><p>The second way to flow data is from view to the source.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/806/1*J9HlatntVC6t4DNLAWZ9Xw.png" /></figure><p>We deal with it, e.g. when clicking on a button. In this case, the click event is listened for. When the user clicks the button, information about it is sent to the component and the function is called:</p><pre>import { Component } from &#39;@angular/core&#39;;</pre><pre>@Component({<br>  selector: &#39;app-root&#39;,<br>  template: `&lt;button (click)=&quot;onShowText()&quot;&gt;Show text&lt;/button&gt;<br>             &lt;span *ngIf=&quot;show&quot;&gt;Hidden text&lt;/span&gt;`<br>})</pre><pre>export class AppComponent {<br>  show: boolean = false;<br>  <br>  onShowText() {<br>    this.show = !this.show;<br>  }<br>}</pre><h3>Two-way binding</h3><p>Two-way binding is nothing more than a combination of both types of data flow.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/797/1*EQGbGPIurGvmzbpqrTLyoQ.png" /></figure><p>It transfers data from the component to the template view and from the template view to the component, which can be seen by running the following code:</p><pre>import { Component } from &#39;@angular/core&#39;;</pre><pre>@Component({<br>  selector: &#39;app-root&#39;,<br>  template: `&lt;input [(ngModel)]=&quot;value&quot;&gt;&lt;span&gt;{{value}}&lt;/span&gt;`,<br>})</pre><pre>export class AppComponent {<br>  value: string = &#39;Joe&#39;;<br>}</pre><p>As you enter each character, the input value is sent to a variable in the component, which causes it to change and update the view. It is important to remember to import FormsModule from ‘@angular/forms’ when using [(ngModel)]. Otherwise, we may get an error.</p><h3>Summary</h3><p>Two-way data binding is the basic Angular mechanism with which we can easily listen to an event and display updated data. This mechanism is often used in template-driven forms, while in more complex forms it is recommended to use reactive forms.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=19c5e6ebe268" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Angular: Workspace and application configuration files]]></title>
            <link>https://medium.com/@matsal.dev/angular-workspace-and-application-configuration-files-3b02b07f7126?source=rss-274566d9a85a------2</link>
            <guid isPermaLink="false">https://medium.com/p/3b02b07f7126</guid>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[typescript]]></category>
            <dc:creator><![CDATA[Mateusz Salamon]]></dc:creator>
            <pubDate>Fri, 06 May 2022 21:54:50 GMT</pubDate>
            <atom:updated>2022-05-06T21:54:50.713Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/799/1*aRYvzMa_wkbhDGnCR_a5Tw.png" /></figure><p>After creating a new application using the Angular framework, not only the source files appear in our application folder. In addition to them, configuration files have also been created that play a very important role, although usually little is mentioned about them. If you are curious about what they are for, this article is for you.</p><h3>Workspace configuration files</h3><p>These types of files include:</p><p><strong>.editorconfig</strong></p><p>This file contains the configuration of the code editor. Thanks to it, developers working in different editors can work on a uniform-looking code style. This file allows you to specify, among other things, the size of the indentation, the width of the tab stop, the type of character encoding, or specify whether to remove the space characters preceding the new line.</p><p><strong>.gitignore</strong></p><p>Thanks to it, we can determine which files will not be tracked when changing their content. By default it includes for example node_modules and dist folders.</p><p><strong>README.md</strong></p><p>In this file, we can describe our project in the Markdown language.</p><p><strong>angular.json</strong></p><p>Lets you set separate property values for the development, production, and test environments. It includes, among other things, the ability to set a budget for production and define the paths to the style sheet files and scripts. It also contains information about the project version, its name, type, schemas, and more.</p><p><strong>tsconfig.json</strong></p><p>It contains the basic Typescript configuration for the project. We can define a whole lot of requirements that Typescirpt will watch over while writing the code, for example, whether we want to work with “strict” mode or not.</p><p><strong>package.json</strong></p><p>This file contains information about all dependencies contained in the project. We can modify the commands used to run the development, test, and production versions in the console.</p><p><strong>package-lock.json/yarn.lock</strong></p><p>It contains information about all packages installed in node_modules. It is automatically generated when modifying node_modules or package.json. It allows optimizing the package installation process, enables better visibility of changes in the tree, when comparing the file with other versions of the project, and also ensures reliability as it guarantees the installation of exactly the same dependencies.</p><h3>Application configuration files</h3><p>These types of files include:</p><p><strong>.browserslistrc</strong></p><p>Following the definition from <a href="https://github.com/browserslist/browserslist">Github</a>: “The config to share target browsers and Node.js versions between different front-end tools.”</p><p><strong>karma.conf.js</strong></p><p>The configuration file of the tool allows you to display the tests performed in the browser. The file allows you to define, for example, the browser in which we want to display the test results, the port, and the framework, e.g. jasmine.</p><p><strong>tsconfig.app.json</strong></p><p>It extends the main tsconfig.json file, specifies compiler options and files. It is used to build an application.</p><p><strong>tsconfig.spec.json</strong></p><p>It specifies the configuration for testing the application. In “types” array we can determine the kind of testing framework. It is usually jasmine.</p><h3>Summary</h3><p>Knowing the role of individual configuration files is especially important when starting work with a project. A good set of configuration properties results in better and faster code writing. If you want to know more details, visit the official<a href="https://angular.io/guide/workspace-config"> Angular Documentation</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3b02b07f7126" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>