<?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 Douglas M. Barcellos on Medium]]></title>
        <description><![CDATA[Stories by Douglas M. Barcellos on Medium]]></description>
        <link>https://medium.com/@dougmbarcellos?source=rss-46a353a15a93------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*H8hbomOVt0c9r9bG.</url>
            <title>Stories by Douglas M. Barcellos on Medium</title>
            <link>https://medium.com/@dougmbarcellos?source=rss-46a353a15a93------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 14:06:04 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@dougmbarcellos/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 16 & Jest | Quick guide]]></title>
            <link>https://dougmbarcellos.medium.com/angular-16-jest-quick-guide-c720774241c7?source=rss-46a353a15a93------2</link>
            <guid isPermaLink="false">https://medium.com/p/c720774241c7</guid>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[jest]]></category>
            <dc:creator><![CDATA[Douglas M. Barcellos]]></dc:creator>
            <pubDate>Wed, 23 Aug 2023 01:47:26 GMT</pubDate>
            <atom:updated>2023-08-24T01:43:22.159Z</atom:updated>
            <content:encoded><![CDATA[<p>From version 16, Angular enable us to use Jest “natively”. But, before proceeding, it is important to clarify that the integration is in an experimental state.</p><p>First, let’s create a new Angular workspace:</p><pre>ng new angular-jest</pre><p>Inside the workspace, install the Jest dependencies:</p><pre>cd angular-jest</pre><pre>npm install jest jest-environment-jsdom @types/jest --save-dev</pre><p>Next step is change the builder in <strong>angular.json</strong> configuration for <strong>test</strong> target:</p><pre>&quot;test&quot;: {<br>  &quot;builder&quot;: &quot;@angular-devkit/build-angular:karma&quot;, // karma -&gt; jest<br>  ...<br>}</pre><p>And keep only the <strong>polyfills</strong> and <strong>tsConfig</strong> options:</p><pre>&quot;test&quot;: {<br>  &quot;builder&quot;: &quot;@angular-devkit/build-angular:jest&quot;,<br>  &quot;options&quot;: {<br>    &quot;polyfills&quot;: [<br>      &quot;zone.js&quot;,<br>      &quot;zone.js/testing&quot;<br>    ],<br>    &quot;tsConfig&quot;: &quot;tsconfig.spec.json&quot;<br>  }<br>}</pre><p>Last step is change “jasmine” for “jest” in <strong>types </strong>option in <strong>tsconfig.spec.json</strong> file:</p><pre>{<br>  &quot;extends&quot;: &quot;./tsconfig.json&quot;,<br>  &quot;compilerOptions&quot;: {<br>    &quot;outDir&quot;: &quot;./out-tsc/spec&quot;,<br>    &quot;types&quot;: [&quot;jest&quot;] // jasmine -&gt; jest<br>  },<br>  &quot;include&quot;: [<br>    &quot;src/**/*.spec.ts&quot;,<br>    &quot;src/**/*.d.ts&quot;<br>  ]<br>}</pre><p>Wow 🎉! Now the environment is ready to run tests with Jest:</p><pre>ng test</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/785/1*DMEsLCQjy8dIRfH1vE0cSQ.png" /></figure><p>If you want to learn more about the future of testing in Angular, read this article created by the Angular team:</p><p><a href="https://blog.angular.io/moving-angular-cli-to-jest-and-web-test-runner-ef85ef69ceca">Moving Angular CLI to Jest and Web Test Runner</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c720774241c7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Angular 16 | Reading Route Parameters with Input() in an Explicit Way]]></title>
            <link>https://dougmbarcellos.medium.com/angular-16-reading-route-parameters-with-input-in-an-explicit-way-18ade42a9831?source=rss-46a353a15a93------2</link>
            <guid isPermaLink="false">https://medium.com/p/18ade42a9831</guid>
            <category><![CDATA[angular-routing]]></category>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[angular-router]]></category>
            <category><![CDATA[angular-16]]></category>
            <dc:creator><![CDATA[Douglas M. Barcellos]]></dc:creator>
            <pubDate>Sun, 16 Jul 2023 20:10:01 GMT</pubDate>
            <atom:updated>2023-07-16T22:38:22.419Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*vyV9qT19egjp1CF3.jpg" /><figcaption>Generated by BlueWillow AI</figcaption></figure><blockquote>One of the changes that Angular brought in its latest version was the possibility to get route data using the<strong>@Input()</strong> decorator. However, this generated a discussion in the community:</blockquote><blockquote><strong>Can there be confusion about the purpose of @Input?</strong></blockquote><blockquote>Next, we will understand the functionality and apply a change that will make the visibility of <strong>Input’s</strong> of the <strong>Router </strong>clearer.</blockquote><h4>Enabling the use of @Input in the Router</h4><p>To use the functionality, we need to change the Router by adding the withComponentInputBinding() function for standalone applications or the bindToComponentInputs property for modules:</p><pre>const routes: Routes = [{ path: &#39;page/:id&#39;, component: PageComponent, }, ];</pre><pre>bootstrapApplication(App, {<br>  providers: [provideRouter(routes, withComponentInputBinding())],<br>});</pre><pre>@NgModule({<br>  imports: [<br>    RouterModule.forRoot(routes, {<br>      bindToComponentInputs: true<br>    })<br>  ],<br>})<br>export class AppModule {}</pre><h4>Getting parameters</h4><p>From this point, we can already get the id of the route page/:id in the PageComponent through the @Input:</p><pre>@Component({<br>  // ...<br>  template: `&lt;div&gt;Page id = {{id}}&lt;/div&gt;`,<br>})<br>export class PageComponent {<br>  // Acessando rota /page/1 aplica valor &quot;1&quot; ao id.<br>  @Input() id: string = &#39;&#39;; <br>}</pre><p>However, when viewing the code above without the comment, we cannot say for sure if this @Input is from a route or is passed through a parent component.</p><h4>The trick ⚡️</h4><p>To make it clear what the purpose of the @Input is without having to add comments, we can use the aliases @RouteParam and @RouteQueryParam:</p><pre>import {<br>  Component,<br>  Input as RouteParam, // Para parâmetros /page/:id<br>  Input as RouteQueryParam, // Para queryStrings /page/:id?name=home<br>} from &#39;@angular/core&#39;;<br><br>@Component({<br>  // ...<br>  template: `&lt;div&gt;Page id = {{id}}&lt;/div&gt;`,<br>})<br>export class PageComponent {<br>  @RouteParam() id: string = &#39;&#39;;<br>  @RouteQueryParam() name: string = &#39;&#39;;<br>}</pre><p>This way, whenever we view the code, we can understand the data source of the property.</p><p>Example of use in StackBlitz:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fstackblitz.com%2Fedit%2Fangular16-router-input-decorator%3Fembed%3D1%26file%3DREADME.md&amp;display_name=StackBlitz&amp;url=https%3A%2F%2Fstackblitz.com%2Fedit%2Fangular16-router-input-decorator%3Fembed%3D1%26file%3DREADME.md&amp;image=https%3A%2F%2Fsocial-img.staticblitz.com%2Fprojects%2Fangular16-router-input-decorator%2F4131a8afe4ebc83ba597e96d835c7a93&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=stackblitz" width="745" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/534a494ff130cac3c9ddfaa9b463d9ad/href">https://medium.com/media/534a494ff130cac3c9ddfaa9b463d9ad/href</a></iframe><h4>Conclusion</h4><p>The discussion raised is valid and I agree that there may be confusion about the use of @Input. The form presented comes to make it more perceptible what the decorator is actually doing. This way, we make the code clearer.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=18ade42a9831" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Angular 16 | Lendo parâmetros de rotas com Input() de maneira mais explícita]]></title>
            <link>https://dougmbarcellos.medium.com/angular-16-lendo-par%C3%A2metros-de-rotas-com-input-de-maneira-mais-expl%C3%ADcita-9cd8458fab08?source=rss-46a353a15a93------2</link>
            <guid isPermaLink="false">https://medium.com/p/9cd8458fab08</guid>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[decorators]]></category>
            <category><![CDATA[angular-16]]></category>
            <category><![CDATA[angular-router]]></category>
            <category><![CDATA[angular-routing]]></category>
            <dc:creator><![CDATA[Douglas M. Barcellos]]></dc:creator>
            <pubDate>Thu, 13 Jul 2023 17:07:24 GMT</pubDate>
            <atom:updated>2023-07-16T18:41:00.663Z</atom:updated>
            <content:encoded><![CDATA[<h3>Angular 16 | Lendo parâmetros de rotas com Input() de maneira explícita</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*vyV9qT19egjp1CF3.jpg" /><figcaption>Imagem gerada por BlueWillow AI</figcaption></figure><blockquote>Uma das mudanças que o Angular trouxe nesta última versão foi a possibilidade de obter os dados da rota utilizando o decorator <strong>@Input()</strong>. Porém isso gerou uma discussão na comunidade:</blockquote><blockquote><strong>Pode haver confusão no entendimento da finalidade do @Input?</strong></blockquote><blockquote>A seguir vamos entender a funcionalidade e aplicar uma mudança que tornará a visibilidade de <strong>@Input’s</strong> do <strong>Router </strong>mais clara.</blockquote><h4>Habilitando o uso do @Input no Router</h4><p>Para utilizar a funcionalidade precisamos alterar o Router adicionando a função withComponentInputBinding() para aplicações<strong> standalone </strong>ou a propriedade bindToComponentInputs para <strong>módulos</strong>:</p><pre>const routes: Routes = [{ path: &#39;page/:id&#39;, component: PageComponent, }, ];</pre><pre>bootstrapApplication(App, {<br>  providers: [provideRouter(routes, withComponentInputBinding())],<br>});</pre><pre>@NgModule({<br>  imports: [<br>    RouterModule.forRoot(routes, {<br>      bindToComponentInputs: true<br>    })<br>  ],<br>})<br>export class AppModule {}</pre><h4>Obtendo parâmetros</h4><p>A partir deste momento já conseguimos obter o <strong>id</strong> da rota page/<strong>:id</strong> no PageComponent através do @Input:</p><pre>@Component({<br>  // ...<br>  template: `&lt;div&gt;Page id = {{id}}&lt;/div&gt;`,<br>})<br>export class PageComponent {<br>  // Acessando rota /page/1 aplica valor &quot;1&quot; ao id.<br>  @Input() id: string = &#39;&#39;; <br>}</pre><p>Porém ao visualizar o código acima sem o comentário não conseguimos dizer com certeza se esse @Input é de uma rota ou é passado através de um componente pai.</p><h4>O truque ⚡️</h4><p>Para deixarmos claro qual é a finalidade do @Input sem ter que adicionar comentários, podemos utilizar os alias @RouteParam e @RouteQueryParam:</p><pre>import {<br>  Component,<br>  Input as RouteParam, // Para parâmetros /page/:id<br>  Input as RouteQueryParam, // Para queryStrings /page/:id?name=home<br>} from &#39;@angular/core&#39;;<br><br>@Component({<br>  // ...<br>  template: `&lt;div&gt;Page id = {{id}}&lt;/div&gt;`,<br>})<br>export class PageComponent {<br>  @RouteParam() id: string = &#39;&#39;;<br>  @RouteQueryParam() name: string = &#39;&#39;;<br>}</pre><p>Desta forma sempre que visualizarmos o código conseguimos entender qual é a fonte de dados da propriedade.</p><p>Exemplo de uso no StackBlitz:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fstackblitz.com%2Fedit%2Fangular16-router-input-decorator%3Fembed%3D1%26file%3Dsrc%252Fmain.ts&amp;display_name=StackBlitz&amp;url=https%3A%2F%2Fstackblitz.com%2Fedit%2Fangular16-router-input-decorator%3Fembed%3D1%26file%3Dsrc%252Fmain.ts&amp;image=https%3A%2F%2Fsocial-img.staticblitz.com%2Fprojects%2Fangular16-router-input-decorator%2F5a22ec011e73dbdb160a294b3e2f0eb5&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=stackblitz" width="745" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/f2cd127b352e6654bf96785c8cb788fe/href">https://medium.com/media/f2cd127b352e6654bf96785c8cb788fe/href</a></iframe><h4>Conclusão</h4><p>A discussão levantada é válida e concordo que pode haver confusão no entendimento do uso do @Input. A forma apresentada vem para deixar mais perceptível o que o decorator está fazendo de fato. Dessa forma deixamos o código mais claro.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9cd8458fab08" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>