<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Matheus Palma</title>
    <description>The latest articles on Forem by Matheus Palma (@mmatheuspalma).</description>
    <link>https://forem.com/mmatheuspalma</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F183029%2Fdeaad12d-2deb-4b1b-9341-36dc10f16345.jpg</url>
      <title>Forem: Matheus Palma</title>
      <link>https://forem.com/mmatheuspalma</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/mmatheuspalma"/>
    <language>en</language>
    <item>
      <title>I know why you don't use Typescript</title>
      <dc:creator>Matheus Palma</dc:creator>
      <pubDate>Tue, 10 May 2022 22:00:18 +0000</pubDate>
      <link>https://forem.com/mmatheuspalma/i-know-why-you-dont-use-typescript-45in</link>
      <guid>https://forem.com/mmatheuspalma/i-know-why-you-dont-use-typescript-45in</guid>
      <description>&lt;p&gt;Since always software developers face problems of compatibility and performance of their software, the challenge is immense. Because, in addition to the concern with the hardware of the device that the software will run, there are still problems with the OS (Operating System) of the device.&lt;/p&gt;

&lt;p&gt;In the development of cross-platform applications, concerns are even greater, as it is necessary to create specific solutions for each OS and hardware. In web development, we find the problems of cross-platform development, devices, operating systems and browsers extremely different.&lt;/p&gt;

&lt;p&gt;In current times, when we talk about browsers, these problems are increasingly simple to solve, because the trend is for them to have a gradually more reusable base, an example of this is Chromium-based browsers and software, which share the same code base.&lt;/p&gt;

&lt;p&gt;Over the years, technological evolution has become evident, bringing devices with increasingly smaller or giant screens with internet access, that is, that interact with web technologies. We have extremes where it is possible to have access to the same Site from a smart watch with a 1.3-inch display or an 85-inch smart television, notice that we are not only talking about extremely different sizes, but also about accessibility, compatibility, UX and UI.&lt;/p&gt;

&lt;p&gt;20 years ago these problems were unimaginable, and there is no doubt about it, as there was no need or possibility to access a Site via watch or television. At that time many people were only concerned about accessing ICQ via Dial-up Internet on a Tube Monitor.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frtz86mizzqco3pmnm9p2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frtz86mizzqco3pmnm9p2.png" alt="ICQ 1998"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“In my day we programmed in ActionScript inside Netscape“ — some old developer.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;And why do we talk so much about compatibility and reuse if we haven't even started talking about TypeScript yet? With the evolution of technology, we have greater complexity within software, the code base of a software is increasingly complex and difficult to maintain, and without a doubt, we need compatibility, standardization, reuse and the organization working together. And this is where TypeScript comes in.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is TypeScript?
&lt;/h2&gt;

&lt;p&gt;TypeScript is a programming language maintained by Microsoft. It is made up of a superset of JavaScript and adds optional static “typing” to the language.&lt;/p&gt;

&lt;p&gt;TypeScript was designed for the development of large applications and “transforms” it all to JavaScript, so that very little performance is lost in exchange for a lot of productivity and organization, in addition to having all JavaScript compatibility, since everything that is “transformed” is nothing but JavaScript.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftz84zr4shieiz7iaqc3j.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftz84zr4shieiz7iaqc3j.png" alt="TypeScript on the left and JavaScript on the right"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“What is a JavaScript superset? What is “Typing”?“ — Me, 2015&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  What is a JavaScript superset?
&lt;/h2&gt;

&lt;p&gt;A JavaScript superset refers to having an incremented or rather tuned JavaScript. You always have the latest version of ECMAScript available, that is, by installing the latest version of TypeScript you will have access to the latest features available in JavaScript, and not least we have a language 100% compatible with JavaScript, regardless of version.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is “Type” in TypeScript?
&lt;/h2&gt;

&lt;p&gt;“Typing” in programming languages ​​it has the role of identifying “things” in order to facilitate the documentation, organization and identification of data models. And TypeScript is no different, we have the interface implementation, type, decorator and enum, in addition to the class inherited from JavaScript, which has improvements such as extends and implements.&lt;/p&gt;

&lt;p&gt;In the example below using interface, we have a function that takes only one parameter of a certain type.&lt;/p&gt;

&lt;p&gt;First, let’s define what the “person” object should contain:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftgc2o6yccjdo2amr9zm6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftgc2o6yccjdo2amr9zm6.png" alt="Interface that defines the data model that a “person” must have."&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Then we create a function that receives the person object, and writes it to the console:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F625fv1qr1flupq6bxqyw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F625fv1qr1flupq6bxqyw.png" alt="The printPersonInfo function receives the person parameter, whose parameter type is an interface called IPerson."&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If I try to pass an incompatible parameter, Transpiler/Linter will return a message saying that the parameter is incorrect:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3lyqp3f7o7ry9rtdl8fd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3lyqp3f7o7ry9rtdl8fd.png" alt="Linter warning"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Therefore, we have the possibility to document your code, and when the application is large, this makes all the difference.&lt;/p&gt;

&lt;h2&gt;
  
  
  TypeScript Resistance
&lt;/h2&gt;

&lt;p&gt;The non-implementation of TypeScript is not only associated with the learning curve, but also because of the fear of breaking something that already works. This was one of the main reasons I didn't start using TypeScript earlier.&lt;/p&gt;

&lt;p&gt;When I started to study the topic, more deeply in 2016, specifically when Angular 2 started to adopt it, I found 3 main points not to use TypeScript, and they were:&lt;/p&gt;

&lt;h3&gt;
  
  
  1. There are alternatives
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Flow.js
&lt;/h4&gt;

&lt;p&gt;Flow.js gives you the possibility to check the quality of your code at development time through “typing”.&lt;/p&gt;

&lt;h4&gt;
  
  
  ReasonML/ReScript (formerly BuckleScript)
&lt;/h4&gt;

&lt;p&gt;ReScript is a language heavily inspired by JavaScript, has many similarities with JavaScript and runs on top of ReasonML, and promises to deliver a high level code. However, it requires knowledge in functional paradigm.&lt;/p&gt;

&lt;p&gt;And indeed they are good alternatives, but in my opinion one is too basic and the other too complex, in a way, of course, it varies according to the complexity of the project. Nowadays, there is no doubt that TypeScript is indeed one of the best options for large applications, if not the one with the best cost-benefit ratio.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Not compatible with Babel
&lt;/h3&gt;

&lt;p&gt;In fact, in 2016 it was not possible to use TypeScript and Babel together, which made it a risky choice, since thousands of plug-ins existed within Babel, however, this is no longer a problem. Since, we can easily include both tools and this is very good for those who have a JavaScript project and want to gradually migrate to TypeScript.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Large existing project
&lt;/h3&gt;

&lt;p&gt;This is a concern for many, but we already know that babel and TypeScript can work together. Furthermore, we know that TypeScript is nothing more than “tuned” JavaScript that “transforms” all code into regular JavaScript.&lt;/p&gt;

&lt;p&gt;It means that we can use JavaScript and TypeScript together without any problem. The only thing we need to do is tell the TypeScript/Linter settings that we want them not to apply Type checks inside JavaScript files, so we can migrate all code to TypeScript little by little, right?&lt;/p&gt;

&lt;h2&gt;
  
  
  Final considerations
&lt;/h2&gt;

&lt;p&gt;The reasons for not using TypeScript scared me in 2016, but I saw many benefits ahead of it, but most of these reasons are no longer valid these days, and maybe some of the reasons I mentioned may have taken you away from TypeScript.&lt;/p&gt;

&lt;p&gt;TypeScript can even be considered an optional tool, however it has been considered a necessity, specifically because it brings numerous benefits and few or almost no negative points.&lt;/p&gt;

&lt;p&gt;It is important to point out that the organization, standardization and compatibility of all software depends exclusively on the development team, and TypeScript is one of the best options to facilitate all this organization and standardization while maintaining all JavaScript software compatibility.&lt;/p&gt;

&lt;h4&gt;
  
  
  References
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.typescriptlang.org" rel="noopener noreferrer"&gt;https://www.typescriptlang.org&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://rescript-lang.org" rel="noopener noreferrer"&gt;https://rescript-lang.org&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://flow.org" rel="noopener noreferrer"&gt;https://flow.org&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Follow Storyblok and stay updated ;)
&lt;/h4&gt;

</description>
      <category>javascript</category>
      <category>typescript</category>
      <category>programming</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Capybara pure CSS ( SCSS )</title>
      <dc:creator>Matheus Palma</dc:creator>
      <pubDate>Fri, 27 Sep 2019 11:20:35 +0000</pubDate>
      <link>https://forem.com/mmatheuspalma/capybara-pure-css-scss-2dce</link>
      <guid>https://forem.com/mmatheuspalma/capybara-pure-css-scss-2dce</guid>
      <description>&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/mmatheuspalma/embed/ooOQvZ?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
      <category>codepen</category>
    </item>
    <item>
      <title>Capybara with pure CSS</title>
      <dc:creator>Matheus Palma</dc:creator>
      <pubDate>Mon, 08 Jul 2019 13:11:23 +0000</pubDate>
      <link>https://forem.com/mmatheuspalma/capybara-with-pure-css-c12</link>
      <guid>https://forem.com/mmatheuspalma/capybara-with-pure-css-c12</guid>
      <description>&lt;p&gt;2 years ago on a frontend meetup, i'm back to home decided to create an capybara with pure CSS&lt;/p&gt;

&lt;p&gt;&lt;a href="https://codepen.io/mmatheuspalma/pen/ooOQvZ"&gt;https://codepen.io/mmatheuspalma/pen/ooOQvZ&lt;/a&gt;&lt;/p&gt;

</description>
      <category>capybara</category>
      <category>css</category>
      <category>scss</category>
      <category>pug</category>
    </item>
    <item>
      <title>Async &amp; Await, finally we have the multi-thread in javascript?</title>
      <dc:creator>Matheus Palma</dc:creator>
      <pubDate>Tue, 25 Jun 2019 16:36:26 +0000</pubDate>
      <link>https://forem.com/mmatheuspalma/go-make-async-use-cases-for-async-functions-3lbn</link>
      <guid>https://forem.com/mmatheuspalma/go-make-async-use-cases-for-async-functions-3lbn</guid>
      <description>&lt;p&gt;With the new features of ES5 we can build async functions quickly.&lt;/p&gt;

&lt;p&gt;Spoiler: Unfortunately, by the language design, the &lt;code&gt;async&lt;/code&gt; and &lt;code&gt;await&lt;/code&gt; keywords on JS functions actually don't allow us to do tasks at the same time with multi-threads like the name sound's, actually is the opposite, so we are able to resolve a task and then go to another task. Is more to a Synchronous way.&lt;/p&gt;

&lt;p&gt;Let's code!!&lt;/p&gt;

&lt;p&gt;First we need to create the function that we need to &lt;code&gt;wait&lt;/code&gt; for, this function will check if the number is odd or even, here we can have many possibilities, the point here is to have a Promise function, like we have in the http requests, that wait's for a response from the API.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;isOdd&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Promise&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;reject&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;isOdd&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;isOdd&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
      &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="nx"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`the number &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; is odd`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
      &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;reject&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`the number &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; is even`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;At the traditional way, the 'Promise' will be executed, and we get the 'response' value from the &lt;code&gt;Promise&lt;/code&gt; by using the 'then' method, imagine that can turn in a infinite cascade if we have a &lt;code&gt;Promise&lt;/code&gt; that return's a new &lt;code&gt;Promise&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;allNumbersAreOdd&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;number1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;number2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;isOdd&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;number1&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;isOdd&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;number2&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;all numbers are odd&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}).&lt;/span&gt;&lt;span class="k"&gt;catch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;});&lt;/span&gt;
  &lt;span class="p"&gt;}).&lt;/span&gt;&lt;span class="k"&gt;catch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So doing maintenance can be hard, depending on the size of the code.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="nx"&gt;allNumbersAreOdd&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// "the number 2 is even"&lt;/span&gt;
&lt;span class="nx"&gt;allNumbersAreOdd&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// "all numbers are odd"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Using the async feature, we are able to add the keyword &lt;code&gt;await&lt;/code&gt; in front of the &lt;code&gt;async&lt;/code&gt; functions ( a http request for example or the promise that we create above which is &lt;code&gt;async&lt;/code&gt; ), and that allow us to wait for the response of the function before proceed, and using that along with the &lt;code&gt;try &amp;amp; catch&lt;/code&gt; we can do the error treatment easily.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;numberIsOdd&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;numberIsOdd&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;isOdd&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;numberIsOdd&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;  
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="nx"&gt;numberIsOdd&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// "the number 5 is odd"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If we need call more than one promises, is easy &lt;br&gt;
do maintenance compared to the traditional way, because we can treat the errors in the same function&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;allNumbersAreOdd&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;number1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;number2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;isOdd&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;number1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;isOdd&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;number2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;all numbers are odd&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;  
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="nx"&gt;allNumbersAreOdd&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// "the number 2 is even"&lt;/span&gt;
&lt;span class="nx"&gt;allNumbersAreOdd&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// "all numbers are odd"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>javascript</category>
      <category>ecmascript</category>
      <category>typescript</category>
      <category>async</category>
    </item>
    <item>
      <title>Go learn together, (code) =&gt; return english;</title>
      <dc:creator>Matheus Palma</dc:creator>
      <pubDate>Mon, 24 Jun 2019 01:51:48 +0000</pubDate>
      <link>https://forem.com/mmatheuspalma/go-learn-together-code-return-english-26lb</link>
      <guid>https://forem.com/mmatheuspalma/go-learn-together-code-return-english-26lb</guid>
      <description>&lt;h3&gt;
  
  
  Hi, greetings
&lt;/h3&gt;

&lt;p&gt;I am a senior frontend engineer, and I want to improve my english skills this year, also teach about using javascript and php tools like react, vue, angular, lumen and typescript.&lt;/p&gt;

&lt;p&gt;if you can, just help me learn more about English (conversation, verbs and pronunciation).&lt;/p&gt;

&lt;p&gt;My native language is portuguese, my english level is A2 accordig to OOPT ( Oxford Online Placement Test )&lt;/p&gt;

&lt;p&gt;Graciously,&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
