<?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 Ciro Nunes on Medium]]></title>
        <description><![CDATA[Stories by Ciro Nunes on Medium]]></description>
        <link>https://medium.com/@cironunesdev?source=rss-c21d4da150d1------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*gcr-cF28Dza3_o4AwTE8EA.jpeg</url>
            <title>Stories by Ciro Nunes on Medium</title>
            <link>https://medium.com/@cironunesdev?source=rss-c21d4da150d1------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 10:27:54 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@cironunesdev/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[How I Quickstart ReasonML Apps]]></title>
            <link>https://medium.com/@cironunesdev/how-i-quickstart-reasonml-apps-44d58bb24c1?source=rss-c21d4da150d1------2</link>
            <guid isPermaLink="false">https://medium.com/p/44d58bb24c1</guid>
            <category><![CDATA[functional-programming]]></category>
            <category><![CDATA[reasonml]]></category>
            <category><![CDATA[boilerplate]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[front-end-development]]></category>
            <dc:creator><![CDATA[Ciro Nunes]]></dc:creator>
            <pubDate>Tue, 09 Jun 2020 09:27:44 GMT</pubDate>
            <atom:updated>2020-06-09T09:27:44.267Z</atom:updated>
            <content:encoded><![CDATA[<p>Just want to see the code? Jump straight into the <a href="https://github.com/cironunes/reasonreact-starter">template</a> repository and follow the instructions.</p><h3>Introducing the ReasonReact Starter</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eKIwBB43K-Rxc1yaebbdYw.png" /><figcaption>github.com/cironunes/reasonreact-starter</figcaption></figure><h3>Why should you use my template repository instead of the official bsb themes?</h3><p>The official ReasonReact template comes with a lot of unnecessary things I always delete and it doesn’t have much set up in terms of testing and building for production. So I decided to create an opinionated <a href="https://github.com/cironunes/reasonreact-starter">template</a> that does that all for me.</p><h4>Pros</h4><ul><li>Less steps to get started (clone the repo, install the dependencies and go)</li><li>Faster build (Parcel FTW)</li><li>Only one index.html file</li></ul><h4><strong>Cons</strong></h4><ul><li>Not official</li><li>Less intuitive (you have to go to my GitHub profile to find it)</li></ul><h3>Getting Started</h3><ol><li>Clone the repository from GitHub: git clone https://github.com/cironunes/reasonreact-starter.git</li><li>Install the dependencies: yarn install</li><li>Develop: yarn start</li><li>Test: yarn test</li><li>Build: yarn build</li></ol><h3>Feedback is welcome</h3><p>Let me know in the comments if you have any questions and/or suggestions. I hope you enjoy it! ✌🏻</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=44d58bb24c1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[An UX lesson from an ATM machine]]></title>
            <link>https://medium.com/@cironunesdev/a-ux-lesson-from-a-atm-machine-82289653bfb6?source=rss-c21d4da150d1------2</link>
            <guid isPermaLink="false">https://medium.com/p/82289653bfb6</guid>
            <category><![CDATA[funny]]></category>
            <category><![CDATA[ux]]></category>
            <dc:creator><![CDATA[Ciro Nunes]]></dc:creator>
            <pubDate>Sun, 07 Jan 2018 10:08:09 GMT</pubDate>
            <atom:updated>2019-03-27T23:40:01.049Z</atom:updated>
            <content:encoded><![CDATA[<p>This is not a technical post as I usually write, but rather something funny that happened to me and I wanted to share with you:</p><blockquote>I have been to Romania and got my card stuck in the ATM machine. A simple UX improvement could have prevented that!</blockquote><p>Last year I presented at the <a href="http://devfest.ro/">GDG DevFest Romania</a> and took the opportunity to take some time to rest over there.</p><p>The conference was awesome: great venue and speakers, beautiful city and what really took my attention, really warm and welcoming people! However, one thing that happened over there almost ruined the trip, <strong>I&#39;ve got my credit card stuck in the ATM machine</strong>!</p><h4>How did it happen?</h4><p>I&#39;ve put the credit card in the machine and after selecting the amount desired and putting my password, the machine gave me back the money right away without asking me to take out the card.</p><blockquote>Myself and my wife got so hooked into checking out the design of the bills 😂, that we didn&#39;t even bother to take the card out. After a few seconds the machine gave a beep and suck the card in explaining that it is a security measure.</blockquote><h4>How could that have been prevented?</h4><p>Yes, we could have been more cautious and pay attention in taking the card out before taking the money. However the experience could be improved to avoid this kind of mistake (and not make me think about it) by <strong>simply not giving the money until I take the card out of the machine</strong>.</p><h4>Wrapping up</h4><p>I love to think about those situations in order to improve my skills. One thing that always amazes me is how little tiny details in the design of applications can make a huge impact! I hope you enjoyed the story.</p><p>Luckily I had more cards to use during the trip, otherwise I would have no money to enjoy my vacations in the beautiful Iași city. I leave you here with some photos of the trip:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kUHLPFaxZm3jV7Q6KlDxIQ.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4D9sMc7uRX2yi6fWXbU7ig.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iAQiZLdxj6TGCDOGRYBc-Q.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*0bA4LbEUEt_HJRG-B0SwjQ.jpeg" /></figure><p>BTW, You can check more stories like this one in my <a href="https://cironunes.com/">website</a>. 👋🏻</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=82289653bfb6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Testing with the Angular HttpClient API]]></title>
            <link>https://medium.com/netscape/testing-with-the-angular-httpclient-api-648203820712?source=rss-c21d4da150d1------2</link>
            <guid isPermaLink="false">https://medium.com/p/648203820712</guid>
            <category><![CDATA[https]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[angular]]></category>
            <dc:creator><![CDATA[Ciro Nunes]]></dc:creator>
            <pubDate>Mon, 21 Aug 2017 10:33:13 GMT</pubDate>
            <atom:updated>2018-02-02T20:38:50.669Z</atom:updated>
            <content:encoded><![CDATA[<h4>Embracing Observables and Immutability FTW</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eb7bFq8M96F6mAMcOIQXIg.jpeg" /></figure><p>The HttpClientTestingModule<strong> </strong>makes it easier to mock requests using the HttpTestingController<strong> </strong>service. In this post we’ll learn how to setup our tests and see real examples of how it can be used.</p><h3>Series</h3><p>This post is part of the HttpClient API series:</p><ol><li><a href="https://medium.com/@cironunesdev/the-new-angular-httpclient-api-9e5c85fe3361">The new Angular </a><a href="https://medium.com/@cironunesdev/the-new-angular-httpclient-api-9e5c85fe3361">HttpClient API</a></li><li>Testing with the Angular HttpClientTesting API</li></ol><h3>Demo</h3><p>We will create a simple GitHub API service that can <strong>get users</strong> and make <strong>searches</strong>. More precisely we will:</p><ul><li>Create the GithubApiService and write tests for it.</li><li>Consume the service created in our GithubComponent to list users and make searches and write tests for it. (this part is not covered in this post)</li></ul><blockquote>You can jump straight to the code you want. Check this <a href="http://github.com/cironunes/httpclient-testing">GitHub repository</a>.</blockquote><h3>Unit testing services with HttpClient</h3><h4>The service</h4><p>As mentioned before, our service will allow us to get users and make searches. It&#39;ll have two methods getUsers and search.</p><p><em>Notice how we throw an error in case the consumer tries to search for a non supported type:</em></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/efea7459ece53ccdd179e4cccd92f4fe/href">https://medium.com/media/efea7459ece53ccdd179e4cccd92f4fe/href</a></iframe><p>This example should be fun enough for us to write some tests for.</p><h4>Setup</h4><p>Now we setup the TestBed importing the HttpClientTestingModule and providing the HttpTestingController. Of course we also provide the service we&#39;re testing:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cf2cdfe6e2ba11751200ba819e62725b/href">https://medium.com/media/cf2cdfe6e2ba11751200ba819e62725b/href</a></iframe><p>Notice that for convenience we saved the injector and the providers we&#39;ll use in our tests in variables. Another option would be to use the <a href="https://angular.io/api/core/testing/inject">inject</a> function.</p><p>We also run HttpTestingController#verify to make sure that there are no outstanding requests:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/dfbe11092f45f7b437e235e8045d8d55/href">https://medium.com/media/dfbe11092f45f7b437e235e8045d8d55/href</a></iframe><h4>Mocking</h4><p>You can use the HttpTestingController to mock requests and the flush method to provide dummy values as responses. As the HTTP request methods return an Observable, we subscribe to it and create our expectations in the callback methods:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/698b6e81aa4b11eb1dd644964157fe97/href">https://medium.com/media/698b6e81aa4b11eb1dd644964157fe97/href</a></iframe><h4>Dealing with errors</h4><p>In this case we&#39;re using the error callback of the subscribe method. We also use the expectNone matcher to confirm that the request wasn&#39;t made:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fa38f44d28c8fbd7d40838c45fea2949/href">https://medium.com/media/fa38f44d28c8fbd7d40838c45fea2949/href</a></iframe><h4>Testing parameters</h4><p>In that case we can verify the request.params to assert if the request was made with the correct parameters. As the HttpParams#set method is immutable, the result is predictable and the tests easy to write:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a222bd616f2ff94187820162ca6d58aa/href">https://medium.com/media/a222bd616f2ff94187820162ca6d58aa/href</a></iframe><h3>Wrapping up</h3><p>There’s a very simple and common flow for creating the tests:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/677/1*1aa8a2efAZ2oVsmYl11zAQ.png" /></figure><p>1- Subscribe to the results of a request</p><p>2- Mock the request using expectOne, expectNone or match</p><p>3- flush the request passing dummy values (in case of expectNone this step isn&#39;t necessary)</p><h3>What&#39;s next</h3><p>In the next post we&#39;ll cover testing interceptors. Stay tuned.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=648203820712" width="1" height="1" alt=""><hr><p><a href="https://medium.com/netscape/testing-with-the-angular-httpclient-api-648203820712">Testing with the Angular HttpClient API</a> was originally published in <a href="https://medium.com/netscape">Netscape</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The new Angular HttpClient API]]></title>
            <link>https://medium.com/angular-in-depth/the-new-angular-httpclient-api-9e5c85fe3361?source=rss-c21d4da150d1------2</link>
            <guid isPermaLink="false">https://medium.com/p/9e5c85fe3361</guid>
            <category><![CDATA[https]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[http-client]]></category>
            <category><![CDATA[rxjs]]></category>
            <category><![CDATA[angular]]></category>
            <dc:creator><![CDATA[Ciro Nunes]]></dc:creator>
            <pubDate>Mon, 14 Aug 2017 06:23:53 GMT</pubDate>
            <atom:updated>2020-04-09T20:00:09.860Z</atom:updated>
            <content:encoded><![CDATA[<h4>Giving us back the control</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8NX1BJ5azRg2uhNnTgwUTg.jpeg" /><figcaption>Control room where all the HTTP requests are handled :)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/743/1*J70xM5LGoRFUdd_Odha5Ug.png" /></figure><blockquote><a href="https://medium.com/angular-in-depth"><strong><em>AngularInDepth</em></strong></a><strong><em> is moving away from Medium. </em></strong><a href="https://indepth.dev/the-new-angular-httpclient-api/"><strong><em>This article</em></strong></a><strong><em>, its updates and more recent articles are hosted on the new platform </em></strong><a href="https://indepth.dev/"><strong><em>inDepth.dev</em></strong></a></blockquote><h3>Series</h3><p>This post is part of the HttpClient API series:</p><ol><li>The new Angular HttpClient API</li><li><a href="https://medium.com/netscape/testing-with-the-angular-httpclient-api-648203820712">Testing with the Angular </a><a href="https://medium.com/netscape/testing-with-the-angular-httpclient-api-648203820712">HttpClientTesting API</a></li></ol><p>The HttpClient API was introduced in the version 4.3.0. It is an evolution of the existing HTTP API and has it&#39;s own package @angular/common/http. This article gives you an overview of the new main features the new client introduces. For the in-depth look under that hood of the HttpClient check out <a href="https://blog.angularindepth.com/insiders-guide-into-interceptors-and-httpclient-mechanics-in-angular-103fbdb397bf">Insider’s guide into interceptors and HttpClient mechanics in Angular</a>.</p><p>One of the most notable changes is that now the response object is a JSON by default, so there&#39;s no need to parse it anymore. We can do:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/25c6b026a47ce94db5027dc326f51a0f/href">https://medium.com/media/25c6b026a47ce94db5027dc326f51a0f/href</a></iframe><p>Rather than:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a06e8469b60870fd5d0ec00bed7c5732/href">https://medium.com/media/a06e8469b60870fd5d0ec00bed7c5732/href</a></iframe><p>However if you&#39;re still interested in the whole Response object you can observe for it:</p><pre>// HttpClient<br>this.http.get(&#39;…&#39;, <strong>{ observe: &#39;response&#39; }</strong>);</pre><h3>Query parameters</h3><p>One thing that might not be as intuitive is the way that it handles query parameters. You can&#39;t just really pass a Plain Old JavaScript Object (POJO) over and expect it to be assigned as a query parameter of the request like you would with any other option that can be passed to the options object of the GET call.</p><pre>import { HttpParams } from &#39;@angular/common/http&#39;;</pre><pre>const <strong>params</strong> = new HttpParams().set(&#39;q&#39;, &#39;cironunes&#39;);</pre><pre>this.http.<strong>get</strong>(&#39;...&#39;, <strong>{ params }</strong>);</pre><p>This is a bit verbose. Luckily there&#39;s already a <a href="https://github.com/angular/angular/pull/18490">pull request</a> in place to enable the usage of object maps for parameters and headers of GET requests.</p><h3>Type checking responses</h3><p>Thanks to <a href="https://www.typescriptlang.org/docs/handbook/generics.html">TypeScript Generics</a> you type HTTP method you’re calling and the response will get be of that same type:</p><pre><strong>interface LoginResponse {<br>  accessToken: string;<br>  accessExpiration: number;<br>}</strong></pre><pre>this.http.post<strong>&lt;LoginResponse&gt;</strong>(&#39;api/login&#39;, {<br>  login: &#39;foo&#39;,<br>  password: &#39;bar&#39;<br>}).subscribe(data =&gt; {<br>  console.log(data.accessToken, data.accessExpiration);<br>});</pre><h3>Requesting non-JSON data</h3><p>Although it’s the most common, sometimes you’ll deal with different sorts of data. This is supported via the responseType property.</p><pre>this.http.get(&#39;...&#39;, { responseType: &#39;text&#39; }); <br>responseType?: &#39;arraybuffer&#39; | &#39;blob&#39; | &#39;json&#39; | &#39;text&#39;</pre><p>In this case you don’t need to type the response as the reponseType already do the trick.</p><h3>Interceptors</h3><p>The most exciting thing of the HttpClient is the introduction of Interceptors which allow middleware logic to be inserted in the pipeline. Let&#39;s take a quick look at how it works.</p><p>First of all let&#39;s create an interceptor. An Interceptor needs to implement the HttpInterceptor interface which is about implementing the intercept method.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7b182913c56462bf1fab873654ac6b4b/href">https://medium.com/media/7b182913c56462bf1fab873654ac6b4b/href</a></iframe><p>The intercept method receives an HttpRequest and must return an stream of HttpEvent of type HttpResponse. As the Request and Response objects are immutable — which makes it easier to predict and test, we use the clone method to mutate the Response object.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2563b5b8dea6314d518fa73b2ccd2861/href">https://medium.com/media/2563b5b8dea6314d518fa73b2ccd2861/href</a></iframe><p>You register them like that:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d116ce033db607e35a75809b6e22f2de/href">https://medium.com/media/d116ce033db607e35a75809b6e22f2de/href</a></iframe><p>If you want to register many interceptors you can just put more items in the providers array.</p><pre>providers: [<br>  { provide: HTTP_INTERCEPTORS, useClass: First, multi: true },<br>  { provide: HTTP_INTERCEPTORS, useClass: Second, multi: true }<br>]</pre><h3>Listening for progress</h3><p>Another very cool feature is that you can subscribe for events like the upload or download progress via reportProgress option. In a file upload example it would be like that:</p><pre>const req = new <strong>HttpRequest</strong>(&#39;POST&#39;, &#39;upload/file&#39;, file, {<br>  <strong>reportProgress</strong>: true<br>});</pre><pre>this.http.request(req)<br>  .subscribe(event =&gt; {<br>    if (event.type === <strong>HttpEventType.UploadProgress</strong>) {<br>      console.log(event.total, event.loaded);<br>    }<br>  });</pre><h3>Wrapping up</h3><p>The HttpClient API is awesome. Besides favouring the most common use cases, it enforces once again the usage of Observables and Immutable objects whenever it makes sense. That makes using it easier and easy to test code that uses it.</p><h3>What’s next?</h3><p>I’ll cover testing with the HttpClientTestingModule in the next post. Stay tuned.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9e5c85fe3361" width="1" height="1" alt=""><hr><p><a href="https://medium.com/angular-in-depth/the-new-angular-httpclient-api-9e5c85fe3361">The new Angular HttpClient API</a> was originally published in <a href="https://medium.com/angular-in-depth">Angular In Depth</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Angular 2 e o futuro]]></title>
            <link>https://medium.com/@cironunesdev/angular-2-e-o-futuro-42ae695404b2?source=rss-c21d4da150d1------2</link>
            <guid isPermaLink="false">https://medium.com/p/42ae695404b2</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[angularjs]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Ciro Nunes]]></dc:creator>
            <pubDate>Mon, 05 Oct 2015 23:27:58 GMT</pubDate>
            <atom:updated>2015-10-05T23:27:58.747Z</atom:updated>
            <content:encoded><![CDATA[<h3>do desenvolvimento Front-end</h3><h4>Por que uma nova versão?</h4><p><em>Essa história foi escrita durante a preparação da palestra </em><a href="http://cnun.es/angular2-future"><em>“Angular 2 e o futuro do desenvolvimento Front-end”</em></a><em>. Nela eu explico porque a nova versão do Angular está sendo criada.</em></p><h3>Angular 1</h3><p>O AngularJS simplificou o Front-end extendendo o HTML para criação de aplicações dinâmicas, o que torna o processo de desenvolvimento extremamente rápido.</p><h4>Features</h4><p><em>Features</em> como a separação de preocupações (estrutura MVC/MVW<em>hatever)</em>, dependency injection, <em>data-binding</em>, rotas, animações e muitas outras que facilitaram a testar o código e desenvolver aplicações profissionais em um curto espaço de tempo.</p><h4>Ferramentas</h4><p>Além disso, o Angular se tornou um ecossistema composto por várias ferramentas. O resultado é um <em>workflow</em> divertido e produtivo ao mesmo tempo:</p><ul><li>Karma (<em>test runner</em>);</li><li>Dgeni (documentação via comentários no código);</li><li>Batarang (<em>debugging);</em></li><li>angular-mocks (<em>unit testing helper</em>);</li><li>Protractor (testes <em>e2e</em>);</li></ul><h4>Módulos reutilizáveis</h4><p>Criar módulos reutilizáveis ficou tão fácil que vários começaram a aparecer. Uma busca por <strong><em>&#39;angular-&#39;</em></strong> e <strong><em>&#39;ng-&#39;</em></strong> no NPM mostra um total de mais de 5 mil (sem contar o Bower), o que agiliza ainda mais o processo de desenvolver aplicações usando o Angular.</p><h4>Popularidade e comunidade</h4><p>No GitHub é o terceiro projeto com mais <em>stars </em>e<em> </em>o sexto com mais <em>forks. </em>Uma comunidade se formou e vários grupos de <em>meetup </em>existem em todo o mundo.</p><h4>Equipe</h4><p>O projeto é mantido por uma equipe do Google e mais de mil contribuidores que mandam <em>pull requests</em>, reportam <em>bugs</em>, sugerem <em>features</em>, melhoram a documentação, em geral melhoram a qualidade do projeto cada vez mais.</p><blockquote>Se o Angular 1 é esse sucesso todo, então por que será criada a versão 2?</blockquote><p><strong>Porque pode ser ainda melhor!</strong></p><h4>Timing</h4><p>Na época em que a primeira versão foi criada os browsers ainda não suportavam recursos incríveis como Web Components (muito parecidos com as diretivas do Angular), as novas features da ES2016/2017(como os módulos), Web Workers, entre outros.</p><h4>Decisões de design</h4><p>Algumas decisões tomadas na primeira vez em que o projeto foi construído se mostraram problemáticas ao longo do tempo. Um exemplo claro disso é o <a href="https://docs.angularjs.org/api/ng/type/$rootScope.Scope#$digest"><em>$digest</em></a> <em>cycle </em>famoso por levar a problemas de performance.</p><h4>Browser support</h4><p>Infelizmente muitos desses recursos não são suportados em alguns browsers que aplicações profissionais precisam dar suporte, então o time do Angular decidiu criar uma nova versão, da melhor forma possível, sem se preocupar com suporte de <em>browsers</em>, ou seja uma versão para os <em>evergreen browsers</em> (aqueles que implementam a maior quantidade de padrões web)<em>.</em></p><h4>Pesquisa</h4><p>Aproveitando que estavam começando o projeto novamente, pesquisaram e <a href="https://drive.google.com/drive/folders/0B7Ovm8bUYiUDR29iSkEyMk5pVUk">documentaram</a> a melhor forma de implementar cada parte do projeto (Router, DI, Change Detection, etc) . E com o <em>feedback </em>da comunidade revisaram pontos problemáticos do <em>framework</em>.</p><h3>O futuro do desenvolvimento Front-end</h3><p>O Angular 2 atualmente está em Alpha Preview (o que significa que já podemos começar a experimentar) e já mostra novidades empolgantes:</p><ul><li>Novo sistema de <em>change detection </em>baseado em árvores (mais rápido e previsível);</li><li>Performance dos <em>bindings</em> de 3 a 5 vezes via diferentes estratégias de <em>change detection</em>;</li><li><em>Router</em> baseado em componentes e respeitando as URLs;</li><li>Novo sistema de <em>dependency injection </em>que possibilita agora carregar componentes sob demanda;</li><li>Suporte a padrões web citados anteriormente: Web Components, ES2016/2017, Web Workers, etc, que são o futuro do desenvolvimento;</li></ul><p>O Angular 2 junta o melhor do Angular 1.x e sua filosofia com os melhores recursos que serão disponibilizados nos browsers.</p><p><strong>E aí?! Preparado para o futuro?</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=42ae695404b2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Esclarecendo alguns mitos sobre o AngularJS]]></title>
            <link>https://medium.com/@cironunesdev/esclarecendo-alguns-mitos-sobre-o-angularjs-1643d4317e75?source=rss-c21d4da150d1------2</link>
            <guid isPermaLink="false">https://medium.com/p/1643d4317e75</guid>
            <dc:creator><![CDATA[Ciro Nunes]]></dc:creator>
            <pubDate>Tue, 28 Oct 2014 20:48:32 GMT</pubDate>
            <atom:updated>2014-10-29T15:35:29.226Z</atom:updated>
            <content:encoded><![CDATA[<p>Frequentemente em conferências, listas de discussão e no Twitter, escuto algumas afirmações sobre o AngularJS que não fazem o menor sentido. Resolvi escrever este post para esclarecer alguns destes mitos.</p><p><strong><em>Disclaimer 1:</em></strong><em> As opiniões deste post são baseadas em minha experiência trabalhando com o framework e envolvimento com a sua incrível comunidade</em>.</p><p><strong><em>Disclaimer 2: </em></strong><em>EU NÃO SOU O DONO DA VERDADE! Caso não concorde com quaisquer um dos esclarecimentos aqui feitos, deixe o seu comentário e terei o maior prazer em reavaliar os meus argumentos.</em></p><blockquote>#1: “A Google não dá tanta importância para o projeto”</blockquote><p>Mais de <a href="https://docs.google.com/presentation/d/1-M5U0B6JI2JKU2ibVmU-xKkR7a88Uz1ZN0pc2lEuGzE/edit#slide=id.g48b143717_069">1600 aplicações</a> internas da empresa utilizam o framework. Destaque para o DoubleClick que é a base da tecnologia de anúncios para criar, movimentar e gerenciar publicidade digital para compradores de todo o mundo, criadores e vendedores (e como sabemos, a maior parte da renda da empresa vem da venda de anúncios).</p><p>Também vale lembrar que uma equipe de mais de 10 engenheiros altamente qualificados trabalham full-time no projeto AngularJS pelo Google.</p><blockquote>#2: “A Google pode abandonar o projeto a qualquer momento assim como fez com vários outros”</blockquote><p>O AngularJS é um projeto open source. Mesmo que a Google não tenha mais interesse nele, existe uma comunidade de mais de 1000 <a href="https://github.com/angular/angular.js/graphs/contributors">contribuidores</a> apaixonados pelo framework que é o <a href="https://github.com/search?q=stars%3a%3E1&amp;s=stars&amp;type=Repositories">top</a> 5 em stars e forks no GitHub.</p><h4><em>Como GDEs (Google Developer Expert) temos informações privilegiadas sobre os produtos da Google e podemos garantir que não existe nenhuma intenção em abandonar o projeto no momento.</em></h4><blockquote>#3: “O framework é tão ruim que está sendo reescrito”</blockquote><p>Recentemente a versão 1.3 foi lançada e ela é considerada a mais incrível até então. Apesar disso, o time do Angular não está satisfeito. Eles acreditam que por terem que suportar os browsers antigos (IE9+), o framework deixa de evoluir, e muito!</p><p>A versão 1.3 foi a última a suportar IE9 e agora, o foco é o lançamento da versão 2.0, destinada aos &quot;evergreen&quot; browsers (IE11+ e Chrome, Firefox, Opera, Safari em suas últimas versões) escrita em ES6, utilizando o que a linguagem tem de melhor e até mesmo a estendendo para deixar o framework ainda mais incrível.</p><p>Confira o <a href="http://angularjs.blogspot.com.br/2014/10/ng-europe-angular-13-and-beyond.html">post no blog oficial anunciando os planos para a versão 2.0.</a></p><blockquote>#4 “O data-binding do Angular é baseado em um setInterval que fica rodando a cada segundo, verificando por mudanças”</blockquote><p>Fazendo uma simples <a href="https://github.com/angular/angular.js/search?utf8=%E2%9C%93&amp;q=setInterval">busca</a> no repositório oficial por “setInterval” vemos que o único lugar onde esse statement é usado, é no serviço $interval (que encapsula o setInterval do browser para aumentar a testabilidade). Para saber mais sobre como funciona o data-binding no AngularJS, leia essa <a href="http://stackoverflow.com/questions/9682092/databinding-in-angularjs#answer-9693933">resposta do criador do framework no StackOverflow</a>.</p><blockquote>#5: “O Angular é bom para aplicações pequenas, mas não serve para aplicações maiores por problemas de performance”</blockquote><p>Na wiki do repositório do Angular no GitHub, tem uma <a href="https://github.com/angular/angular.js/wiki/Projects-using-AngularJS">lista de projetos</a> que utilizam o framework. Dentre eles, projetos pequenos, médios, grandes e enormes.</p><p>O Angular foi criado com base no seu sistema de injeção de dependências que permite evitar uma quantidade enorme de boilerplate e aumenta consideravelmente a testabilidade do código, isso o torna ideal para aplicações robustas.</p><p>O maior problema de performance é conhecido e fácil de resolver. Ele está relacionado a uma das principais features do framework, o <a href="https://docs.angularjs.org/guide/databinding">data-binding</a>. A quantidade de $watchers criados na aplicação pode deixar o processo de dirty-checking extremamente lento, entretanto, isso não é um problema até a aplicação atingir mais de 2000 $watchers (o que é raro). Caso você passe por isso, não entre em pânico, existem recursos para te ajudar:</p><p><a href="https://chrome.google.com/webstore/detail/angularjs-batarang/ighdmehidhipcmcojjgiloacoafjmpfk?hl=en"><strong>Batarang</strong></a><strong>: </strong>ferramenta de debugging que permite saber o custo dos watchers na aplicação.</p><p><a href="https://docs.angularjs.org/guide/expression"><strong>One-time binding</strong></a><strong>: </strong>após o bind de uma propriedade, você pode desregistrar os $watchers correspondentes, evitando o aumento do número de $watchers e consequente lentidão do app.</p><p><a href="https://docs.angularjs.org/api/ng/directive/ngModelOptions"><strong>Debounce</strong></a><strong>: </strong>é possível atrasar o processo de $digest utilizando a propriedade ng-model-options nos inputs para evitar lentidão na aplicação durante a interação do usuário.</p><h4>É importante ressaltar que o one-time binding e o debounce foram incluídos na versão 1.3 que contém outras melhorias de performance no core do framework.</h4><p>Para mais técnicas de otimização, sugiro o excelente artigo do @toddmotto: “<a href="http://www.binpress.com/tutorial/speeding-up-angular-js-with-simple-optimizations/135">Speeding up AngularJS apps with simple optimizations</a>”</p><p>Feitos os esclarecimentos, aproveito para convidá-los para utilizar e fazer parte da incrível comunidade do AngularJS. ☺</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1643d4317e75" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AngularJS cares about accessibility!]]></title>
            <link>https://medium.com/@cironunesdev/angularjs-cares-about-accessibility-607785648c58?source=rss-c21d4da150d1------2</link>
            <guid isPermaLink="false">https://medium.com/p/607785648c58</guid>
            <dc:creator><![CDATA[Ciro Nunes]]></dc:creator>
            <pubDate>Tue, 07 Oct 2014 22:26:23 GMT</pubDate>
            <atom:updated>2014-10-08T19:38:30.207Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/603/1*UJNKc8ih57AEZzCupo2Euw.jpeg" /></figure><h4>A11y made easy with angular-aria</h4><p>The ARIA attributes are designed to improve the accessibility of Rich Internet Applications. A more know example is the <strong><em>tabindex:</em></strong></p><pre>&lt;form ng-submit=&quot;signUp()&quot;&gt;<br>  &lt;input type=&quot;text&quot; ng-model=&quot;name&quot; tabindex=&quot;1&quot;&gt;<br>  &lt;input type=&quot;text&quot; ng-model=&quot;email&quot; tabindex=&quot;2&quot;&gt;<br>  &lt;button tabindex=&quot;3&quot;&gt;Sign up&lt;/button&gt;<br>&lt;/form&gt;</pre><p>The <strong><em>tabindex</em></strong> attributes in the HTML elements, guide the user through the different controls of the form, making it accessible and also fun to interact with ☺.</p><h3>Introducing the ngAria</h3><p>In the <a href="https://github.com/angular/angular.js/blob/master/CHANGELOG.md#130-rc3-aggressive-pacification-2014-09-23">1.3.0-rc3</a> the angular-aria module was added to the project as a separate module. The <strong><em>ngAria</em></strong> makes a11y easy, adding ARIA attributes automatically to the elements.</p><p>Currently, the following ARIA attributes are implemented:</p><ul><li>aria-hidden</li><li>aria-checked</li><li>aria-disabled</li><li>aria-required</li><li>aria-invalid</li><li>aria-multiline</li><li>aria-valuenow</li><li>aria-valuemin</li><li>aria-valuemax</li><li>tabindex</li></ul><p>So that you can write your markup without the ARIA attributes (that honestly, we always forget), because now the <strong><em>ngAria</em></strong> take care of that for you.</p><h4>Installing</h4><p>1. Download it via Bower:</p><pre>bower install —save angular-aria</pre><p>2. Include the script in the HTML.</p><pre>&lt;script src=&quot;bower_components/angular-aria/angular-aria.js&quot;&gt;</pre><p>3. Declare the ngAria module as a dependency of the app</p><pre>angular.module(&#39;myApp&#39;, [&#39;ngAria&#39;]);</pre><p>Profit! Now <strong><em>ngAria </em></strong>is enhancing your markup with ARIA attributes automatically! Isn’t that awesome?</p><h3>Configuring</h3><p>All the attributes are included by default. If you want to turn off some of them, all you need to do is inject the <strong><em>$ariaProvider</em></strong> and use it&#39;s <strong><em>config</em></strong> method:</p><pre>angular.module(‘myApp’, [‘ngAria’])<br> .config(function($ariaProvider) {<br>   $ariaProvider.config({<br>     tabindex: false,<br>     ariaHidden: false<br>   });<br> });</pre><p>The <strong><em>ngAria </em></strong>is pretty new and right now has a very little set o features. The good news is that you can always either open issues for file bugs or request features. Even better, submit pull requests with awesome improvements to the core of AngularJS.</p><h3>Is that all?</h3><p>Of course not! This is only a little piece of work. You should still follow the best practices to make your apps accessible.</p><p>I strong recommend you to take a look at <a href="http://a11yproject.com/">a11yproject.com</a> content for improving your skills.</p><p>You should also take a look at some great tools:</p><ul><li>A complete list of tools for Web Accessibility Evaluation <em>(including color contrast, HTML validation, etc.) </em><a href="http://www.w3.org/WAI/ER/tools/complete">http://www.w3.org/WAI/ER/tools/complete</a></li><li>An Accessibility checklist for your projects <a href="http://a11yproject.com/checklist.html">http://a11yproject.com/checklist.html</a></li><li>A complete list of resources for Accessibility <a href="http://a11yproject.com/resources.html">http://a11yproject.com/resources.html</a></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/846/1*DP0TAPmXhP4eKoARpIk_Zw.png" /><figcaption>A11Y Project checklist</figcaption></figure><p>What about you? Do you care about accessibility?</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=607785648c58" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AngularJS: How to name directives]]></title>
            <link>https://medium.com/@cironunesdev/angularjs-how-to-name-directives-118ac44b81d4?source=rss-c21d4da150d1------2</link>
            <guid isPermaLink="false">https://medium.com/p/118ac44b81d4</guid>
            <dc:creator><![CDATA[Ciro Nunes]]></dc:creator>
            <pubDate>Sun, 21 Sep 2014 17:37:40 GMT</pubDate>
            <atom:updated>2014-09-21T17:37:40.815Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/545/1*aXWZgGsU7t9bpAkv_rhaug.gif" /></figure><p>Quick tips to avoid issues with custom directive names</p><p>AngularJS directives allow us to use our own vocabulary to create semantic HTML components. To take advantage of that we should be aware of how it works to avoid some annoying and hard to find issues.</p><h3>Differences between defining and using</h3><p>Before start digging into the best practices, let&#39;s understand the fundamentals. Let&#39;s see how to define and then, how to use an directive.</p><h4>Defining (the JS)</h4><p>To define a new custom directives all we need to do is use the <strong><em>directive </em></strong>method which expects two parameters: a name and a constructor function.</p><pre>angular.module(&#39;myDirectives&#39;, []).<br> directive(&#39;myAwesomeDirective&#39;, function() {<br>   return {<br>     restrict: &#39;E&#39;,<br>     template: &#39;&lt;h1&gt;This is awesome!&lt;/h1&gt;&#39;<br>   };<br> });</pre><p><strong>In this case, the name must be written using camelCase and each capital letter will represent a dash when we use this directive.</strong></p><h4>Using (the HTML)</h4><pre>&lt;my-awesome-directive&gt;&lt;/my-awesome-directive&gt;</pre><p><strong>In this case, the name must be written using dashes and each dash represents a capital letter from the directive definition.</strong></p><p>The <a href="https://docs.angularjs.org/api/ng/service/$compile">$compile</a> converts from camelCase to dash-separated behind the scenes. So, make sure you use the names correctly otherwise it won&#39;t work.</p><h3>Use an unique preffix</h3><p>I see a lot of times people starting with Angular, which by instinct name their directives with one word like: <strong>&lt;dialog&gt; </strong>or<strong> &lt;tabs&gt;</strong>. The reason why this is not a good ideia is because we can have new HTML elements in the future (HTML6?) named exactly with the same name of our custom directive. BTW this is the case of the <strong>&lt;dialog&gt; </strong>element.</p><p><strong>To avoid naming collision with future HTML elements, use a preffix as a kind of namespace</strong></p><p>A recommended and wide spread convention from the Angular community is to have<strong> two letters preffix names</strong> that identifies your application or library.</p><p>Examples:</p><ul><li>ng- (from the core)</li><li>ui- (from angular-ui)</li><li>my- (common in examples)</li><li>wm- (Wealth Management project)</li></ul><p><strong>Make sure to also avoid the &quot;ng-&quot; which is used for AngularJS core directives.</strong></p><h3>Conclusion</h3><p>TLDR;</p><p>Use camelCase in the JS and dash-separated in the HTML as expected by the AngularJS compiler. Choose an unique two letters preffix for your directives and avoid the &quot;ng-&quot; preffix. Have fun!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=118ac44b81d4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Diretivas AngularJS: isolate scope]]></title>
            <link>https://medium.com/@cironunesdev/diretivas-angularjs-isolate-scope-ed07d11e56c7?source=rss-c21d4da150d1------2</link>
            <guid isPermaLink="false">https://medium.com/p/ed07d11e56c7</guid>
            <dc:creator><![CDATA[Ciro Nunes]]></dc:creator>
            <pubDate>Thu, 03 Jul 2014 21:07:28 GMT</pubDate>
            <atom:updated>2014-08-15T18:19:25.073Z</atom:updated>
            <content:encoded><![CDATA[<p>Diretivas nos permitem estender o HTML e criar nossos próprios elementos. Podemos definir como esses elementos vão se comportar em cada caso usando atributos, bem parecido com os <a href="http://www.smashingmagazine.com/2014/03/04/introduction-to-custom-elements/">Custom Elements</a>. Neste post vamos entender o que é <strong>isolate scope </strong>e como ele funciona.</p><h3>Scope</h3><p>No objeto de definição de uma diretiva, temos a propriedade <strong>scope </strong>que pode se comportar de três formas de acordo com o seu valor:</p><h4>false|default: sem scope</h4><p>Por padrão as diretivas não criam um escopo, ou seja, ela utiliza exatamente o mesmo escopo de onde ela for inserida, podendo modificar seus valores.</p><h4>true: novo scope</h4><p>Quando definido como <strong>true </strong>é definido um novo<strong> scope, </strong>que herda (henraça prototipal) do<strong> scope </strong>pai<strong>.</strong></p><h4><strong>{ foo: &#39;=&#39;, bar: &#39;@&#39;, baz: &#39;&amp;&#39; }: isolate scope</strong></h4><p>O escopo isolado nos permite definir uma API via atributos HTML além de não herdar do escopo pai. Nossos atributos podem receber três valores diferentes que correspondem a como eles irão se comportar:</p><p><strong>=</strong> two-way data-binding</p><p><strong>@</strong> top-down binding</p><p><strong>&amp;</strong> executar um método no escopo do pai</p><p>Não entendeu nada? Não tem problema, vamos ver um exemplo para ajudar.</p><h3>Criando uma diretiva reutilizável usando isolate scope</h3><p>Para entender como o <strong>isolate scope</strong> funciona na pratica, vamos construir uma diretiva que encapsula o funcionamento do componente <a href="http://getbootstrap.com/components/#alerts"><strong>alert</strong></a> do <a href="http://getbootstrap.com/">Bootstrap</a>.</p><p>Você pode ver o resultado final aqui: <a href="http://plnkr.co/edit/vVVO74OxvmGumVdPkUxh?p=preview">http://plnkr.co/edit/vVVO74OxvmGumVdPkUxh?p=preview</a></p><h4>API</h4><p>Repare como usando atributos HTML nós definimos o <strong>tipo</strong> de alerta e como vamos <strong>fechá-la.</strong></p><pre>&lt;my-alert type=”type” close=”close()” ng-hide=”closed”&gt;<br>  &lt;strong&gt;Warning!&lt;/strong&gt; Better check yourself.<br>&lt;/my-alert&gt;</pre><h4>Definindo a diretiva</h4><p>O que queremos fazer é habilitar o two-way data-binding para o model <strong>type </strong>e<strong> </strong>executar o método <strong>close </strong>que for passado para o nosso componente de alerta:</p><pre>app.directive(‘myAlert’, function() {<br>  return {<br>    restrict: ‘EA’, // elemento ou atributo<br>    transclude: true,<br>    templateUrl: ‘alert.html’,<br>    scope: {<br>      type: ‘=’, // two-way data-binding<br>      close: ‘&amp;’ // executa um método no escopo pai<br>    }<br>  };<br>});</pre><p>Nós também poderíamos usar o valor ‘@’ para o atributo <strong>type. </strong>A diferença é que ao invés de esperar o nome do model para habilitar o data-binding, a nossa diretiva passaria a esperar por uma <a href="https://docs.angularjs.org/guide/expression">expressão</a> Angular.</p><pre>&lt;my-alert type=”{{ type }}” close=”close()” ng-hide=”closed”&gt;<br>  &lt;strong&gt;Warning!&lt;/strong&gt; Better check yourself...<br>&lt;/my-alert&gt;</pre><p>A diferença entre ‘@’ e ‘=’ é que usando expressões temos mais controle sobre os valores que são passados para o atributo em questão. Veja um exemplo:</p><pre>&lt;my-alert type=”{{ type || &#39;info&#39; }}”&gt;<br>  &lt;strong&gt;Warning!&lt;/strong&gt; Better check yourself...<br>&lt;/my-alert&gt;</pre><h3>Conclusão</h3><p>Entender como o <strong>isolate scope </strong>funciona é essencial para criar componentes altamente reutilizáveis, flexíveis, customizáveis e auto-contidos. É um grande passo em direção ao domínio do uso das diretivas do AngularJS.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ed07d11e56c7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to unit test AngularJS Decorators]]></title>
            <link>https://medium.com/@cironunesdev/how-to-unit-test-angularjs-decorators-67a28ef29e8d?source=rss-c21d4da150d1------2</link>
            <guid isPermaLink="false">https://medium.com/p/67a28ef29e8d</guid>
            <dc:creator><![CDATA[Ciro Nunes]]></dc:creator>
            <pubDate>Thu, 17 Apr 2014 05:13:35 GMT</pubDate>
            <atom:updated>2014-04-27T19:07:28.894Z</atom:updated>
            <content:encoded><![CDATA[<p>You could use decorators to enhance any kind of AngularJS module. Unit testing a decorator is all about testing the kind of service that you’re dealing with and making sure that the expected behaviour is what actually happens. So, if you’re decorating a service you’ll write tests for services, if you’re decorating directives you’ll write tests for directives (make sense, huh?).</p><p>In this article we will see how to decorate an Angular core directive and unit test it.</p><h4>Decorating a native Angular directive</h4><p>Let’s suppose that we want to augment the <strong>$rootScope</strong> service to log the number of times that the <strong>$apply</strong> method were called.</p><pre>angular.module(&#39;cn.rootScope&#39;, [])<br>  .config(function($provide) {<br>   // create a decorator<br>   $provide.decorator(&#39;$rootScope&#39;, function($delegate) {<br>      // in this case $delegate == $rootScope<br>      // otherwise $delegate would be an array of<br>      // directives registered as the decorator name<br>      var times = 1;</pre><pre>      // augument the apply method to log how many times<br>      // it was called<br>      $delegate.$apply = loggerify($delegate.$apply);</pre><pre>      function loggerify(fn) {<br>        return function() {<br>          fn.apply(this, arguments);<br>          console.log(times);<br>          times += 1;<br>        }<br>      }</pre><pre>      return $delegate;<br>    });<br>  });</pre><h4>Setting up the test environment</h4><p>First of all we need that our test run after load <strong>angular.js</strong> and <strong>angular-mocks.js</strong>. Here is an example considering that we are using Karma and Bower.</p><pre>module.exports = function(config) {<br>  config.set({<br>    basePath: ‘’,<br>    frameworks: [‘jasmine’],<br>    files: [<br>      ‘bower_components/angular/angular.js’,<br>      ‘bower_components/angular-mocks/angular-mocks.js’,<br>      ‘src/*.js’,<br>      ‘test/*.js’<br>    ],<br>    browsers: [‘Chrome’],<br>  });<br>};</pre><h4>Bootstraping the test suite</h4><p>Now that we have all set, let’s bootstrap our test file.</p><pre>describe(‘Decorator: $rootScope’, function() {<br>  // load the angular.module using angular-mocks<br>  beforeEach(module(‘cn.rootScope’));</pre><pre>  var $rootScope;</pre><pre>  // before each spec runs<br>  beforeEach(inject(function(_$rootScope_) {<br>    $rootScope = _$rootScope_;<br>  }));</pre><pre>  // the specs will be here<br>});</pre><h4>Creating our specs</h4><p>In case of our decorator we’ll need only one spec. All we need to do is make sure that for each time that we call the <strong>$apply</strong> method, <strong>console.log</strong> is called with the next value.</p><pre>it(&#39;should log how many times the $apply <br>    method was called&#39;, function() {<br>  spyOn(console, &#39;log&#39;);<br>  $rootScope.$apply();<br>  $rootScope.$apply();<br>  $rootScope.$apply();<br>  expect(console.log).toHaveBeenCalledWith(1);<br>  expect(console.log).toHaveBeenCalledWith(2);<br>  expect(console.log).toHaveBeenCalledWith(3);<br>});</pre><p>This pattern could be used to test pretty much any kind of decorator that augment core services. Have fun!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=67a28ef29e8d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>