<?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>DEV Community: Eulier Gonzalez</title>
    <description>The latest articles on DEV Community by Eulier Gonzalez (@eulier).</description>
    <link>https://dev.to/eulier</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%2F389737%2Fb6b43d11-6de6-4b04-b3e1-05662f4f7e1f.png</url>
      <title>DEV Community: Eulier Gonzalez</title>
      <link>https://dev.to/eulier</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/eulier"/>
    <language>en</language>
    <item>
      <title>Will this show the users’ local time?. Pulling data from Firestore?</title>
      <dc:creator>Eulier Gonzalez</dc:creator>
      <pubDate>Wed, 23 Mar 2022 14:39:41 +0000</pubDate>
      <link>https://dev.to/eulier/will-this-show-the-users-local-time-pulling-data-firestore-1bp9</link>
      <guid>https://dev.to/eulier/will-this-show-the-users-local-time-pulling-data-firestore-1bp9</guid>
      <description>&lt;p&gt;A client ask me that question, and frankly that something that i heard even amount others developers.&lt;/p&gt;

&lt;p&gt;Because at the startup i'm working we're using Firestore as our DB.&lt;/p&gt;

&lt;p&gt;So a make a quick recap on how to respond to this question:&lt;/p&gt;

&lt;p&gt;TL;DR&lt;br&gt;
Yes&lt;/p&gt;

&lt;p&gt;The reason is, since Google Firestore store date &amp;amp; time as &lt;a href="https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/timestamp.proto"&gt;Timestamp&lt;/a&gt;. which follows the &lt;a href="https://www.ietf.org/rfc/rfc3339.txt"&gt;RFC 3339&lt;/a&gt;, that is a format of the &lt;a href="https://www.iso.org/iso-8601-date-and-time-format.html"&gt;ISO 8601&lt;/a&gt;.&lt;br&gt;
An standard to represent date &amp;amp; time using &lt;a href="https://en.wikipedia.org/wiki/Gregorian_calendar"&gt;Gregorian Calendar&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So when we store date &amp;amp; time, it set by default to UTC, you can also change it.&lt;/p&gt;

&lt;p&gt;And we're using &lt;a href="https://momentjs.com/"&gt;momentjs&lt;/a&gt; &lt;a href="https://momentjs.com/docs/#/displaying/format/"&gt;format method&lt;/a&gt; to set that to user's localtime.&lt;/p&gt;

</description>
      <category>node</category>
      <category>javascript</category>
      <category>time</category>
      <category>firebase</category>
    </item>
    <item>
      <title>Contributing to back-end codebase as a front-end for first time.</title>
      <dc:creator>Eulier Gonzalez</dc:creator>
      <pubDate>Thu, 20 May 2021 19:13:22 +0000</pubDate>
      <link>https://dev.to/eulier/contributing-to-back-end-codebase-as-a-front-end-for-first-time-3i27</link>
      <guid>https://dev.to/eulier/contributing-to-back-end-codebase-as-a-front-end-for-first-time-3i27</guid>
      <description>&lt;p&gt;I’ve 4 years of experience working with client-side code (HTML, CSS, JS and Node.js). Thanks to &lt;a href="https://zerotomastery.io/"&gt;Zero To Mastery&lt;/a&gt; i could deep dive in the some major computer science concepts through &lt;a href="https://www.udemy.com/course/master-the-coding-interview-data-structures-algorithms/"&gt;Data Structure and Algorithm Course on Udemy&lt;/a&gt;, &lt;a href="https://www.udemy.com/course/advanced-javascript-concepts/"&gt;JS Advanced Concepts&lt;/a&gt; and improve my journey as a Software Developer by following the &lt;a href="https://www.udemy.com/course/the-complete-junior-to-senior-web-developer-roadmap"&gt;Junior to Senior Web Development 2021&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;It took me (as a non-native english speaker) from april 2020 to feb 2021 to improve myself, daily on it, and eventually i got hired by a startup.&lt;/p&gt;

&lt;p&gt;So, after a month of bootstrap the roadmap in which I made some proof of concepts about chat &amp;amp; authentication systems for Node.js and Django respectively, we finally now gonna build this app.&lt;/p&gt;

&lt;p&gt;There is a backend developer that sets up the basis.&lt;br&gt;
So I want to be effective on learning/understanding the concepts so i can give value to the codebase as soon as possible.&lt;/p&gt;

&lt;h2&gt;
  
  
  Approach
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Investigate/Read through each package at the package.json&lt;/li&gt;
&lt;li&gt;Learn the “why” and “how” it works&lt;/li&gt;
&lt;li&gt;Listen concepts’s pronunciation and verbalize out loud&lt;/li&gt;
&lt;li&gt;Apply those concepts by following the conventions and good practices to our needs (tasks)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let see how it works.&lt;/p&gt;

&lt;p&gt;Note: Due this project is quite small (8 packages), i can afford to do that. Even though the idea here is to understand following a pareto principle 80/20 to complete the task.&lt;br&gt;
If we need to deep dive on more specific uses case, that's another post.&lt;/p&gt;

&lt;p&gt;Edit I: &lt;br&gt;
My intent is to dedicate 1 hours per package, take 3 series of 13 minutes and break of 3 minutes per serie and at the end a total rest of 12-20 minutes.&lt;/p&gt;

</description>
      <category>devjournal</category>
      <category>node</category>
      <category>javascript</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Coupling And Cohesion</title>
      <dc:creator>Eulier Gonzalez</dc:creator>
      <pubDate>Wed, 28 Apr 2021 14:52:27 +0000</pubDate>
      <link>https://dev.to/eulier/coupling-and-cohesion-3hc3</link>
      <guid>https://dev.to/eulier/coupling-and-cohesion-3hc3</guid>
      <description>&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt;&lt;br&gt;
If you know about this, do something better with your time.&lt;/p&gt;

&lt;p&gt;Working for a startup, they tell me to setup an Authentication User using Django.&lt;/p&gt;

&lt;p&gt;I'm a Javascript Developer, with perhaps a skill of 8.8/10, i'd use Python but for educational purpose, so this is kind of new to me.&lt;/p&gt;

&lt;p&gt;Looking at the &lt;a href="https://developer.mozilla.org/en-US/docs/Learn/Server-side/Django/Introduction"&gt;Django Quick Start From Mozilla&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;And later at their &lt;a href="https://docs.djangoproject.com/en/3.2/#the-django-open-source-project"&gt;Django Docs&lt;/a&gt;, in the Design Philosophies link and after reading &lt;a href="http://wiki.c2.com/?CouplingAndCohesion"&gt;Coupling and Cohesion&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I'll argue that in Software Engineering&lt;br&gt;
The less responsabilities and interdependence you have between modules or components, the better.&lt;br&gt;
I'm gonna applied this gem, to my life.&lt;/p&gt;

&lt;p&gt;Have a nice day!&lt;/p&gt;

</description>
      <category>devjournal</category>
      <category>computerscience</category>
      <category>python</category>
      <category>django</category>
    </item>
    <item>
      <title>Web socket and HTTP(s); Intro to simple differences</title>
      <dc:creator>Eulier Gonzalez</dc:creator>
      <pubDate>Tue, 20 Apr 2021 19:30:21 +0000</pubDate>
      <link>https://dev.to/eulier/web-socket-and-http-s-intro-to-simple-differences-38bn</link>
      <guid>https://dev.to/eulier/web-socket-and-http-s-intro-to-simple-differences-38bn</guid>
      <description>&lt;p&gt;In telecommunication a &lt;a href="https://en.wikipedia.org/wiki/Duplex_(telecommunications)"&gt;&lt;strong&gt;duplex&lt;/strong&gt;&lt;/a&gt; communication system is a &lt;strong&gt;point to point&lt;/strong&gt; system composed of 2 or more connected devices.&lt;br&gt;
And it can be:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Full-duplex system, simultaneously&lt;/strong&gt; or bi-directional at time&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--2yz_bgsb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l548oj5c0onjkw8mu24o.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--2yz_bgsb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l548oj5c0onjkw8mu24o.png" alt="Screenshot_2021-04-20 Duplex (telecommunications) - Wikipedia(1)"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Half-duplex system&lt;/strong&gt;, communication is &lt;strong&gt;one direction at time&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ipqjaJny--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uogwfrip1q9famex8mbl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ipqjaJny--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uogwfrip1q9famex8mbl.png" alt="Screenshot_2021-04-20 Duplex (telecommunications) - Wikipedia"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;HTTP 1.1&lt;/strong&gt;, HyperText Transfer Protocol is a &lt;strong&gt;Half-duplex system&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;So writing chat applications using i.e. LAMP Stack, (Linux, Apache, Mysql &amp;amp; PHP), it involve: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Actively sampling the status of the server (Polling) for changes&lt;/li&gt;
&lt;li&gt;Keep track timestamp and &lt;/li&gt;
&lt;li&gt;It’s slower than it should be.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Socket&lt;/strong&gt; have traditionally been the solution for real-time chat application are architected, supplying a bi-directional (&lt;strong&gt;Full-duplex&lt;/strong&gt;) communication channel between the client and the server. It actually use the URI format.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ws://userinfo@host:port/path?query#fragment
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is just a start to wrap your mind around in case you want to understand how &lt;a href="https://socket.io/get-started/chat"&gt;socket.io&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It also contains very helpful &lt;a href="https://github.com/socketio/socket.io/tree/master/examples"&gt;examples&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>node</category>
      <category>computerscience</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Vue Component Design Patterns </title>
      <dc:creator>Eulier Gonzalez</dc:creator>
      <pubDate>Fri, 16 Apr 2021 15:05:17 +0000</pubDate>
      <link>https://dev.to/eulier/vue-component-design-patterns-2d9l</link>
      <guid>https://dev.to/eulier/vue-component-design-patterns-2d9l</guid>
      <description>&lt;p&gt;From &lt;a href="https://www.vuemastery.com/courses/component-design-Patterns/introduction"&gt;Vue Mastery&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Benefits &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Create components easy to use &amp;amp; maintain &lt;/li&gt;
&lt;li&gt;Avoid common mistakes that makes our components more prone to bugs &lt;/li&gt;
&lt;li&gt;Feel empowered to make architectural desition that are best for your app.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Tradeoff&lt;br&gt;
For a lot of use case Component Design Patters might works, but for others it can be an antipattern. &lt;/p&gt;

&lt;p&gt;So, this are guidelines not rules and it's important to understand the potential benefits that best fit, for your application.&lt;/p&gt;

&lt;p&gt;Key features&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Pros (array and object definition style)&lt;/li&gt;
&lt;li&gt;Problems of overly relay on Pros to enhance components&lt;/li&gt;
&lt;li&gt;Slot&lt;/li&gt;
&lt;li&gt;Slot Techniques&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I'll expand more about this topic on following posts. &lt;br&gt;
If you can afford, i'll recommend to invest on Vue Mastery Course.&lt;br&gt;
Don't forget to drink water.&lt;br&gt;
Sleep well.&lt;br&gt;
Take care.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>vue</category>
      <category>architecture</category>
      <category>node</category>
    </item>
    <item>
      <title>Recursion, why is helpful but not in JS, ;(</title>
      <dc:creator>Eulier Gonzalez</dc:creator>
      <pubDate>Sat, 10 Apr 2021 16:23:20 +0000</pubDate>
      <link>https://dev.to/eulier/recursion-why-is-helpful-but-not-in-js-2j4k</link>
      <guid>https://dev.to/eulier/recursion-why-is-helpful-but-not-in-js-2j4k</guid>
      <description>&lt;p&gt;Recursion according to &lt;a href="https://academy.zerotomastery.io/p/master-the-coding-interview-data-structures-algorithms"&gt;DSA Course from Zero To Mastery&lt;/a&gt; is an algorithmn, that allows to define something in terms of itself or a function that call itself.&lt;/p&gt;

&lt;p&gt;For example&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;multiplyBy5&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;num&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;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;num&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;multiplyBy5&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;num&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you can see recursion, is useful for repetitive task.&lt;br&gt;
Of courser iterative solutions are way more better for this small problems.&lt;br&gt;
But when you need to traverse a tree or a graph ( something that is wildly uncommon for Js developer )&lt;/p&gt;

&lt;p&gt;Or validate a Binary Search Tree.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;isValidBST&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;root&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;min&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;max&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;root&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;

    &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;min&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;root&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;val&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="nx"&gt;min&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;val&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;max&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;root&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;val&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="nx"&gt;max&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;val&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;)&lt;/span&gt; 
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;isValidBST&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;root&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;left&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;min&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;root&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;isValidBST&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;root&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;right&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;root&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;max&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;Recursion offers :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;DRY Code (Don't repeate yourself)&lt;/li&gt;
&lt;li&gt;Readability&lt;/li&gt;
&lt;li&gt;Useful when you don't know how deep a data structure is&lt;/li&gt;
&lt;li&gt;Solve problems using a divide and conquer approach&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Tradeofs:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Iterative solution are more efficient, since they don't have additional function call (they don't use the call stack)&lt;/li&gt;
&lt;li&gt;Space complexity and Recursion are not friends&lt;/li&gt;
&lt;li&gt;For new developers it's hard to wrap around their minds&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To solve the space complexity issue, there is something call:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Tail Call Optimization
It allows recursion without increasing the call stack&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;However, and the reason you're here.&lt;/p&gt;

&lt;p&gt;Supringsingly, only [Apple Products*](&lt;a href="https://kangax.github.io/compat-table/es6/#test-proper_tail_calls_(tail_call_optimisation)"&gt;https://kangax.github.io/compat-table/es6/#test-proper_tail_calls_(tail_call_optimisation)&lt;/a&gt;, support this feature.&lt;/p&gt;

&lt;p&gt;The others major js enviroment like, Chrome, Firefox, Edge (client side) and node.js (server side) doesn't support and that might never changes.&lt;/p&gt;

</description>
      <category>devjournal</category>
      <category>javascript</category>
      <category>tutorial</category>
      <category>algorithms</category>
    </item>
    <item>
      <title>Vue-test-utils best practices for DOM finding &amp; Events</title>
      <dc:creator>Eulier Gonzalez</dc:creator>
      <pubDate>Sat, 13 Mar 2021 14:30:02 +0000</pubDate>
      <link>https://dev.to/eulier/vue-test-utils-best-practices-for-dom-finding-events-245j</link>
      <guid>https://dev.to/eulier/vue-test-utils-best-practices-for-dom-finding-events-245j</guid>
      <description>&lt;p&gt;When writing unit test, is helpful to imagine how the actual end user is gonna interact with our component and then we can design the test to replicate that behaviour.&lt;/p&gt;

&lt;p&gt;How do we find DOM elements for testing our component?, here are some of the best practices from &lt;a href="https://www.vuemastery.com"&gt;VueMastery&lt;/a&gt; when finding it.&lt;/p&gt;

&lt;p&gt;Imagine that we use an Id or Class attribute to find a DOM element, but then down the road a designer or developer changes the id or the class of that element, so there’s a better, more future proof way to find elements.&lt;/p&gt;

&lt;p&gt;A solution looks like this, for example with a button&lt;/p&gt;

&lt;p&gt;In our component&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="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;button&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;test&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="err"&gt;”&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;button&lt;/span&gt;&lt;span class="err"&gt;”&lt;/span&gt; &lt;span class="err"&gt;…&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/button&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Give our element a test specific, ID. Now in order to find that we’ll use this.&lt;/p&gt;

&lt;p&gt;In our spec file&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;button&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;wrapper&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;find&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="err"&gt;‘&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;test&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="err"&gt;”&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;button&lt;/span&gt;&lt;span class="err"&gt;”&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="err"&gt;’&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Setting things up this way helps us to decouple the test from the implementation details of that component.&lt;/p&gt;

&lt;p&gt;Now we don’t need to worry about refactoring our test, just because a designer changes some class name around.&lt;br&gt;
This is a recommended practice for production level tests.&lt;/p&gt;

&lt;p&gt;Ok, but what about trigger events?. Again good practices from VueMastery, is by using this.&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;wrapper&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;trigger&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="err"&gt;‘&lt;/span&gt;&lt;span class="nx"&gt;submit&lt;/span&gt;&lt;span class="err"&gt;’&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Writing in this way allow us to decouple the test from the implementation component’s detail. Again future-proofing our test.&lt;/p&gt;

</description>
      <category>vue</category>
      <category>javascript</category>
      <category>testing</category>
      <category>node</category>
    </item>
    <item>
      <title>Vue animation state with GSAP</title>
      <dc:creator>Eulier Gonzalez</dc:creator>
      <pubDate>Fri, 05 Mar 2021 20:05:05 +0000</pubDate>
      <link>https://dev.to/eulier/vue-animation-state-with-gsap-45i7</link>
      <guid>https://dev.to/eulier/vue-animation-state-with-gsap-45i7</guid>
      <description>&lt;p&gt;Little of theory:&lt;br&gt;
We need to understand first “tweening” and why we use state based animation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tween&lt;/strong&gt; (which is something that it use GSAP behind the scene in it's version 3 ) is short for &lt;strong&gt;between&lt;/strong&gt;, so if we want to transition smoothly from 1 to 10, we’ll need to consider all the values between them along with all of their decimals. &lt;/p&gt;

&lt;p&gt;By using Gsap we can have this happen automatically.&lt;br&gt;
So we’ll use this concepts to create a state based animation.&lt;/p&gt;

&lt;p&gt;This examples comes directly from Vue-mastery, so i don't own anything and this is just for educational purposes.&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="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;template&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;{ width: tweenedNumber.toFixed(0) + 'px' }&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;bar&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;span&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;tweenedNumber&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;toFixed&lt;/span&gt;&lt;span class="p"&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="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/span&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;  &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/template&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;script&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;gsap&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;gsap&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;number&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;tweenedNumber&lt;/span&gt;&lt;span class="p"&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="na"&gt;watch&lt;/span&gt;&lt;span class="p"&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="nx"&gt;newValue&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;gsap&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;to&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;$data&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; 
          &lt;span class="na"&gt;duration&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="na"&gt;ease&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;circ.out&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="na"&gt;tweenedNumber&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;newValue&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="na"&gt;methods&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;randomNumber&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kr"&gt;number&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;random&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;800&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="p"&gt;},&lt;/span&gt;
  &lt;span class="nx"&gt;created&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;setInterval&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;randomNumber&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1500&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="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/script&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;style&lt;/span&gt; &lt;span class="nx"&gt;scoped&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;bar&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;padding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="nx"&gt;px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nx"&gt;background&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="err"&gt;#&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="nx"&gt;c3e50&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;border&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="nx"&gt;px&lt;/span&gt; &lt;span class="err"&gt;#&lt;/span&gt;&lt;span class="mi"&gt;16&lt;/span&gt;&lt;span class="nx"&gt;c0b0&lt;/span&gt; &lt;span class="nx"&gt;solid&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nx"&gt;min&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="nx"&gt;px&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="nx"&gt;bar&lt;/span&gt; &lt;span class="nx"&gt;span&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;white&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/style&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can look at the example here:&lt;br&gt;
&lt;a href="https://repl.it/@eulier1/Gsap"&gt;https://repl.it/@eulier1/Gsap&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Key features:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Watcher, it allows us to watch a reactive value and do things when that value changes.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Gsap, on the first parameter we’re passing the data’s option object, to give access to our data and on the second parameter we’re indicating how to animate it.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Tween a short for between and allow us to smoothly transition from 1 to 10 along with all their decimals.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
    </item>
    <item>
      <title>Working with Algolia API. Nuxt Plugins</title>
      <dc:creator>Eulier Gonzalez</dc:creator>
      <pubDate>Thu, 25 Feb 2021 20:18:41 +0000</pubDate>
      <link>https://dev.to/eulier/working-with-algolia-api-nuxt-plugins-1ppk</link>
      <guid>https://dev.to/eulier/working-with-algolia-api-nuxt-plugins-1ppk</guid>
      <description>&lt;p&gt;Here we’re using Algolia to externalize our API. We’re using the most popular way to communicate with an API, Rest methodology.&lt;br&gt;
We’re going to create a plugin to do this, it’s important to only copy the value of search-only, otherwise if you copy the admin-api key, you’re secret will expose to the world, and then they can read index, update, delete or much worse.&lt;br&gt;
We create a &lt;strong&gt;plugin&lt;/strong&gt; that will contain the code to inform Algolia who we are.&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;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;context&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;inject&lt;/span&gt;&lt;span class="p"&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;appId&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;SZEW42EG32&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;apiKey&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;1cb012681351f6a27e7c0133a9f20021&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;

    &lt;span class="nx"&gt;inject&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;dataApi&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="nx"&gt;getHome&lt;/span&gt;
    &lt;span class="p"&gt;})&lt;/span&gt;
    &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;getHome&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;homeId&lt;/span&gt;&lt;span class="p"&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;response&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;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`https://&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;appId&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;-dsn.algolia.net/1/indexes/homes/&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;homeId&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;,{&lt;/span&gt;
            &lt;span class="na"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;X-Algolia-API-Key&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;apiKey&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;X-Algolia-Application-Id&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;appId&lt;/span&gt;
            &lt;span class="p"&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;data&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;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;json&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;data&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;Take note that we’re using the async/await syntactic sugar, thanks to Nuxt use webpack and babel behind the scene, to transform our code in a good old promise that is understood for older browsers.&lt;br&gt;
Lastly we’re using the &lt;strong&gt;&lt;code&gt;inject&lt;/code&gt;&lt;/strong&gt; method to expose the &lt;code&gt;getHome&lt;/code&gt; function to the rest of the app. We’re using a generic name for flexibility, so if you need to change over the course of the project from any other search provider, you can do it easily.&lt;/p&gt;

&lt;p&gt;Include the plugin in the nuxt.config.js&lt;/p&gt;

&lt;p&gt;nuxt.config.js&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;plugins&lt;/span&gt;&lt;span class="p"&gt;:[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;~/plugins/dataApi.js&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and then we can use it in our component, created lifecycle hook. &lt;/p&gt;

&lt;p&gt;home.vue&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="nx"&gt;created&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;home&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;$dataApi&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getHome&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;$route&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;params&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;home&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;home&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Because Nuxt, doesn’t wait for that promise to resolve (&lt;code&gt;async created&lt;/code&gt;), there is a method &lt;strong&gt;&lt;code&gt;asyncData&lt;/code&gt;&lt;/strong&gt; when it comes to works with API, &lt;strong&gt;only available in Nuxt&lt;/strong&gt;. This method, receive is the &lt;code&gt;context&lt;/code&gt; object similar to the plugin. It gets triggers on the Client side routing or in the server side when we hit it.&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="nx"&gt;asyncData&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;&lt;span class="nx"&gt;params&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;$dataApi&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;home&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;$dataApi&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getHome&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;params&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nx"&gt;home&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;I'll leave the apiKey open for a couple of weeks, so you can easily try.&lt;/p&gt;

&lt;p&gt;Take care and enjoy your process.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>node</category>
      <category>devjournal</category>
      <category>vue</category>
    </item>
    <item>
      <title>Company ask me recommendation for Vue 3</title>
      <dc:creator>Eulier Gonzalez</dc:creator>
      <pubDate>Thu, 18 Feb 2021 21:48:07 +0000</pubDate>
      <link>https://dev.to/eulier/company-ask-me-recommendation-for-vue-3-37mk</link>
      <guid>https://dev.to/eulier/company-ask-me-recommendation-for-vue-3-37mk</guid>
      <description>&lt;p&gt;While finished 2 courses from &lt;a href="https://zerotomastery.io/"&gt;Zero To Mastery Academy&lt;/a&gt;, &lt;a href="https://academy.zerotomastery.io/p/advanced-javascript-concepts"&gt;Js Advanced Concept&lt;/a&gt;, &lt;a href="https://academy.zerotomastery.io/p/the-complete-junior-to-senior-web-developer-roadmap"&gt;Junior To Senior Web Developer&lt;/a&gt; and currently learning &lt;a href="https://academy.zerotomastery.io/p/master-the-coding-interview-data-structures-algorithms"&gt;Data Structures and Algorithm&lt;/a&gt; plus &lt;a href="https://www.vuemastery.com/"&gt;Vue 2 - 3&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I'm looking for jobs on Upwork and suddenly a job post ask me couple questions, that i find out relevant to share.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;If you started a brand new project tomorrow, would you personally use Vue 2 or 3, and why?&lt;br&gt;
Vue 3.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;There are certainly benefits of using it and just to mention a couple ones:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Lightweight&lt;/li&gt;
&lt;li&gt;V-model redesign mechanism (which makes more easy to handle and maintain code), make it simpler to handle multiple models with simple payload.&lt;/li&gt;
&lt;li&gt;Reactivity now use Proxy Object instead of Object.defineProperty which benefits from a native object in JavaScript, ergo improve performance.&lt;/li&gt;
&lt;li&gt;Composition API, that makes the code much more modular an easy to debug.&lt;/li&gt;
&lt;li&gt;Typescript support, which makes the code scalable.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;What is your preference, to use Bootstrap as mostly the skeleton and write more custom CSS? Or, to try and do as much as possible with native bootstrap styles and minimal custom CSS?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It's gonna depends on the budget and the client requirements.&lt;br&gt;
If client prioritizes design over boilerplate, use Bootstrap or Vuetify will be a way to go candidate.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is your process for selecting an npm package for a given problem? Lets say I want to find a package for phone number inputs and many meet your requirements, how would you evaluate which repo is best?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The more packages a project has, the more problems we'll have to handle. Stick to native as much as possible, while keep complexity very low. &lt;br&gt;
Repeated code in some circumstances, may benefit more in term of cost/time rather than a package. ( There is a heated debate over this )&lt;/p&gt;

&lt;p&gt;Even so, if I need to choose a package this will roughly be the criteria.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Vue recommendations&lt;/li&gt;
&lt;li&gt;Adoption by the community&lt;/li&gt;
&lt;li&gt;Open source&lt;/li&gt;
&lt;li&gt;Maintainers activity&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you wanna complete my answer, please, feel free to do it.&lt;/p&gt;

</description>
      <category>vue</category>
      <category>javascript</category>
      <category>webdev</category>
      <category>devjournal</category>
    </item>
    <item>
      <title>Interview Question - How to create a text side by side output in node.js (as a diff). From Vanhack</title>
      <dc:creator>Eulier Gonzalez</dc:creator>
      <pubDate>Sun, 24 Jan 2021 21:43:22 +0000</pubDate>
      <link>https://dev.to/eulier/interview-question-how-to-create-a-text-side-by-side-output-in-node-js-as-a-diff-from-vanhack-3oe0</link>
      <guid>https://dev.to/eulier/interview-question-how-to-create-a-text-side-by-side-output-in-node-js-as-a-diff-from-vanhack-3oe0</guid>
      <description>&lt;p&gt;This actually was an interview question from &lt;a href="https://vanhack.com"&gt;VanHack&lt;/a&gt;, a platform for remote digital work.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://gallant-bell-850d88.netlify.app/2021/january/how-to-create-diff-text-output.html"&gt;In my blog i explain the details of this&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;They provide you with &lt;strong&gt;2 assessments&lt;/strong&gt; and give you &lt;strong&gt;24 hours&lt;/strong&gt; to solve it.&lt;/p&gt;

&lt;p&gt;Even thou i couldn't pass all the test cases of the first assessment, it teach/refresh a lot of concepts from Data Structures, Algorithms, Buffers &amp;amp; Stream over traditionally file read.&lt;/p&gt;

&lt;h2&gt;
  
  
  Key concepts
&lt;/h2&gt;

&lt;h3&gt;
  
  
  &lt;a href="https://nodejs.dev/learn/nodejs-buffers"&gt;Node.js Buffers&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;A buffer is an area of memory.&lt;/p&gt;

&lt;p&gt;A simple visualization of a buffer is when you are watching a YouTube video and the red line goes beyond your visualization point: you are downloading data faster than you're viewing it, and your browser buffers it.&lt;/p&gt;

&lt;p&gt;In order words &lt;strong&gt;store data&lt;/strong&gt; to be &lt;strong&gt;process later&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;a href="https://nodejs.dev/learn/nodejs-streams"&gt;Node.js Stream&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Traditionally, when you tell the program to read a file, the file is read into memory, from start to finish, and then you process it.&lt;/p&gt;

&lt;p&gt;Using streams you read it piece by piece, processing its content without keeping it all in memory.&lt;/p&gt;

&lt;p&gt;Streams provide two major advantages:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Memory efficiency&lt;/li&gt;
&lt;li&gt;Time efficiency&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;a href="https://nodejs.org/docs/latest-v12.x/api/readline.html#readline_example_read_file_stream_line_by_line"&gt;ReadLine using CreateReadStream in Node&lt;/a&gt;
&lt;/h3&gt;

&lt;h3&gt;
  
  
  &lt;a href="https://www.bigocheatsheet.com/"&gt;Know your BigO or Asymptomatic Analysis of Data Structures&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Source &lt;br&gt;
&lt;a href="https://github.com/eulier1/sidebyside-text-column"&gt;Github code&lt;/a&gt;&lt;/p&gt;

</description>
      <category>devjournal</category>
      <category>node</category>
      <category>javascript</category>
      <category>challenge</category>
    </item>
    <item>
      <title>Nuxt link prefetch</title>
      <dc:creator>Eulier Gonzalez</dc:creator>
      <pubDate>Mon, 18 Jan 2021 17:18:51 +0000</pubDate>
      <link>https://dev.to/eulier/nuxt-link-prefetch-2mh5</link>
      <guid>https://dev.to/eulier/nuxt-link-prefetch-2mh5</guid>
      <description>&lt;p&gt;Since a month ago, i could afford &lt;a href="https://masteringnuxt.com/"&gt;Mastery Nuxt&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here they're explaining how attribute &lt;code&gt;prefetch&lt;/code&gt; works in &lt;code&gt;&amp;lt;nuxt-link&amp;gt;&lt;/code&gt; tag.&lt;/p&gt;

&lt;p&gt;Nuxt use &lt;code&gt;nuxt-link&lt;/code&gt; that allows to navigate in our webapp, one of the features about this, is by &lt;strong&gt;default&lt;/strong&gt; prefetch the pages that are &lt;strong&gt;linked&lt;/strong&gt; in the &lt;strong&gt;viewport&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;If your app is already pretty busy on first pageview, like if you have a lot of javascript or network traffic, you may want to disable this feature. Don’t worry you have plenty options.&lt;/p&gt;

&lt;h2&gt;
  
  
  Locally disabling
&lt;/h2&gt;

&lt;p&gt;If you want to disable prefetching for a given link just add &lt;code&gt;no-prefetch&lt;/code&gt; on it. &lt;br&gt;
i.e.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;nuxt&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;link&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nx"&gt;to&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;`/home/${home.objectID}`&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;no&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;prefetch&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;home&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;card&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nx"&gt;home&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;home&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/nuxt-link&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Globally disabling
&lt;/h2&gt;

&lt;p&gt;In the &lt;code&gt;nuxt.config.js&lt;/code&gt; in add a property call &lt;code&gt;router&lt;/code&gt; which is an object and add &lt;code&gt;prefetchLinks&lt;/code&gt; to set it false, like this.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;router&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;prefetchLinks&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now you can pick and choose which links to prefetch, this is really handy when it comes to perfomance optimizations&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>vue</category>
      <category>performance</category>
      <category>devjournal</category>
    </item>
  </channel>
</rss>
