<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.10.0">Jekyll</generator><link href="https://kendaganio.com/feed.xml" rel="self" type="application/atom+xml" /><link href="https://kendaganio.com/" rel="alternate" type="text/html" /><updated>2025-10-21T18:32:06+00:00</updated><id>https://kendaganio.com/feed.xml</id><title type="html">kendaganio.com</title><subtitle>Write an awesome description for your new site here. You can edit this line in _config.yml. It will appear in your document head meta (for Google search results) and in your feed.xml site description.</subtitle><entry><title type="html">Rewriting jkbx from Angular 1.x to Vue</title><link href="https://kendaganio.com/2018/02/15/rewriting-jkbx" rel="alternate" type="text/html" title="Rewriting jkbx from Angular 1.x to Vue" /><published>2018-02-15T00:00:00+00:00</published><updated>2018-02-15T00:00:00+00:00</updated><id>https://kendaganio.com/2018/02/15/rewriting-jkbx</id><content type="html" xml:base="https://kendaganio.com/2018/02/15/rewriting-jkbx"><![CDATA[<p>The framework <a href="https://vuejs.org/">Vue</a> has constantly been flashing in my radar as a new shiny thing to learn.
I was still busy upping my React game and had no opportunity to learn new stuff (read: I’m a fucking slob).
But as a resolution of sorts I want to commit code at least once a day. This sets up a good excuse to learn Vue!</p>

<p>Vue was created by this chill dude <a href="https://github.com/yyx990803">Evan You</a>, who at the time was working for Google and Angular. 
He pulled out what he liked about Angular, added in a virtual DOM, stripped it down to remove all the cruft he wouldn’t
need, and made it really lightweight. My first impression was that it really reminds me of the Angular of yore. 
The prefixed directives, the two-way binding, models, and controllers. Man, what a feels trip!</p>

<figure class="highlight"><pre><code class="language-vue" data-lang="vue"><span class="nt">&lt;div</span> <span class="na">id=</span><span class="s">"app"</span><span class="nt">&gt;</span>
  {{ message }}
<span class="nt">&lt;/div&gt;</span></code></pre></figure>

<div class="language-javascript highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="kd">var</span> <span class="nx">app</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">Vue</span><span class="p">({</span>
  <span class="na">el</span><span class="p">:</span> <span class="dl">'</span><span class="s1">#app</span><span class="dl">'</span><span class="p">,</span>
  <span class="na">data</span><span class="p">:</span> <span class="p">{</span>
    <span class="na">message</span><span class="p">:</span> <span class="dl">'</span><span class="s1">Hello Vue!</span><span class="dl">'</span>
  <span class="p">}</span>
<span class="p">})</span>
</code></pre></div></div>
<p><em>Actual “Hello, world!” example from the <a href="https://vuejs.org/v2/guide/">docs</a></em></p>

<h3 id="batteries-included">Batteries included</h3>

<p>Unlike other JS frameworks, Vue has it’s own ecosystem of official packages and plugins.
Just take a look at their <a href="https://github.com/vuejs">github organization page</a> to see what I’m talking about.
From state management, router implementations, to browser dev tools they have all these things ready for your convenience. 
This is really interesting to me because I witnessed the <a href="https://github.com/voronianski/flux-comparison">flux wars</a>
when React was just starting out, and boy have I used a lot of Flux implementations a while back, only for them to be
deprecated in a few months time. I think this is a new-developer-friendly move, you don’t need to stress
about which plugin to go with what, because everything is laid out for you, and that I appreciate a lot.</p>

<p>For this project I used <a href="https://github.com/vuejs/vue-cli">vue-cli</a>, <a href="https://github.com/vuejs/vue-router">vue-router</a>, and 
the beautiful <a href="https://github.com/vuejs/vue-devtools">vue-devtools</a>. Unfortunately I wasn’t able to try out
<a href="https://github.com/vuejs/vuex">vuex</a> because most of my application state is in firebase.</p>

<h3 id="so-what-the-fuck-is-jkbx-anyways">So what the <del>fuck</del> is jkbx anyways?</h3>

<p>Ah, good question. For that I will gratuitously copy-paste a section of <a href="https://github.com/kendaganio/jkbx">jkbx</a>’s README.</p>
<blockquote>
  <p>This project started as a way for me to learn angular.js, we actually found it very useful for parties at the office and it became our own little office plaything. I haven’t touched this project in a few years and thankfully it still works with no maintenance. So this 2018 I wanted to learn something aside from React, and decided to rewrite jkbx in Vue. Enjoy!</p>
</blockquote>

<p>With all of that out of the way, I will now attempt to share my experience learning Vue.</p>

<h3 id="get-on-with-it-already">Get on with it already!</h3>

<p>This project was fairly easy to bootstrap thanks to <code class="language-plaintext highlighter-rouge">vue-cli</code>. Unlike <a href="https://github.com/facebook/create-react-app">create-react-app</a> 
where all the configurations are abstracted, <code class="language-plaintext highlighter-rouge">vue-cli</code> just scaffolds a project with good defaults and some scripts to get you
started quickly.</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>src
├── App.vue
├── components
│   ├── Party.vue
│   ├── Player.vue
│   ├── SplashPage.vue
│   ├── TrackControls.vue
│   ├── TrackMedia.vue
│   └── TrackSearch.vue
├── main.js
└── router
    └── index.js
</code></pre></div></div>

<p>This is the entire <code class="language-plaintext highlighter-rouge">src</code> folder after all of jkbx’s functionality have been ported over.
Vue has no prescribed opinions on how to structure your code, so I leave that discretion to you.</p>

<p>So now I know what you’re thinking, what the hell are <code class="language-plaintext highlighter-rouge">.vue</code> files! Good observation dear friend, 
allow me to show you!</p>

<h3 id="the-vue-instance">The Vue Instance</h3>

<div class="language-javascript highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c1">// https://github.com/kendaganio/jkbx/blob/master/src/main.js</span>
<span class="k">import</span> <span class="nx">Vue</span> <span class="k">from</span> <span class="dl">'</span><span class="s1">vue</span><span class="dl">'</span><span class="p">;</span>
<span class="k">import</span> <span class="nx">VueYoutube</span> <span class="k">from</span> <span class="dl">'</span><span class="s1">vue-youtube</span><span class="dl">'</span><span class="p">;</span>

<span class="k">import</span> <span class="nx">router</span> <span class="k">from</span> <span class="dl">'</span><span class="s1">./router</span><span class="dl">'</span><span class="p">;</span>
<span class="k">import</span> <span class="nx">App</span> <span class="k">from</span> <span class="dl">'</span><span class="s1">./App</span><span class="dl">'</span><span class="p">;</span>

<span class="nx">Vue</span><span class="p">.</span><span class="nx">config</span><span class="p">.</span><span class="nx">productionTip</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span>
<span class="nx">Vue</span><span class="p">.</span><span class="nx">use</span><span class="p">(</span><span class="nx">VueYoutube</span><span class="p">);</span>

<span class="cm">/* eslint-disable no-new */</span>
<span class="k">new</span> <span class="nx">Vue</span><span class="p">({</span>
  <span class="na">el</span><span class="p">:</span> <span class="dl">'</span><span class="s1">#jkbx-app</span><span class="dl">'</span><span class="p">,</span>
  <span class="nx">router</span><span class="p">,</span>
  <span class="na">components</span><span class="p">:</span> <span class="p">{</span>
    <span class="nx">App</span><span class="p">,</span>
  <span class="p">},</span>
  <span class="na">template</span><span class="p">:</span> <span class="dl">'</span><span class="s1">&lt;App/&gt;</span><span class="dl">'</span><span class="p">,</span>
<span class="p">});</span>
</code></pre></div></div>

<p>Each application starts with a Vue instance, this let’s Vue know where to mount the application, and which template to use.
<a href="https://vuejs.org/v2/guide/components.html">Components</a> much like in every other js framework nowadays are reusable nuggets of code, packed in a HTML-looking tag.
These components have lifecycle methods, data definition, and events. I won’t go into much detail about how everything works,
the <a href="https://vuejs.org/v2/guide/">Vue docs</a> is fantastic, and it is by far the easiest for me to use and understand.</p>
<h3 id="the-anatomy-of-a-vue-component">The Anatomy of a Vue Component</h3>

<p>Initially I was adamant to use <a href="https://vuejs.org/v2/guide/single-file-components.html">Single File Components</a>
just because they didn’t fit with my <code class="language-plaintext highlighter-rouge">A E S T H E T I C S</code>. However as I was developing the app I slowly, and this is hard for me to admit,
grew a liking to the idea of having a component in a single file.</p>

<figure class="highlight"><pre><code class="language-vue" data-lang="vue">// Hullo.vue
<span class="nt">&lt;</span><span class="k">template</span><span class="nt">&gt;</span>
  <span class="nt">&lt;h1&gt;</span><span class="si">{{</span> <span class="nx">message</span> <span class="si">}}</span><span class="nt">&lt;/h1&gt;</span>
<span class="nt">&lt;/</span><span class="k">template</span><span class="nt">&gt;</span>

<span class="nt">&lt;</span><span class="k">script</span><span class="nt">&gt;</span>
<span class="k">export</span> <span class="k">default</span> <span class="p">{</span>
  <span class="na">name</span><span class="p">:</span> <span class="dl">'</span><span class="s1">Hullo</span><span class="dl">'</span><span class="p">,</span>
  <span class="na">data</span><span class="p">:</span> <span class="p">{</span>
    <span class="na">message</span><span class="p">:</span> <span class="dl">'</span><span class="s1">What up pimps!</span><span class="dl">'</span>
  <span class="p">}</span>
<span class="p">};</span>
<span class="nt">&lt;/</span><span class="k">script</span><span class="nt">&gt;</span>

<span class="nt">&lt;</span><span class="k">style</span> <span class="na">scoped</span><span class="nt">&gt;</span>
<span class="nt">h1</span> <span class="p">{</span> <span class="nl">font-weight</span><span class="p">:</span> <span class="nb">bold</span> <span class="p">}</span>
<span class="nt">&lt;/</span><span class="k">style</span><span class="nt">&gt;</span></code></pre></figure>

<p>One thing that is still hard for me today is where do I put my CSS in React. With Single File Components I don’t 
need to worry myself with such nonsense, instead I just dump everything in one file and let the fantastic <a href="https://github.com/vuejs/vue-loader">vue-loader</a>
do it’s job. You may add a <code class="language-plaintext highlighter-rouge">scoped</code> attribute to the <code class="language-plaintext highlighter-rouge">style</code> tag and when it’s built the css properties you define will only 
affect the component you wrote it in. It’s really neat.</p>

<h3 id="things-that-i-particulary-liked">Things that I particulary liked</h3>

<p>For every new framework that I learn, I see a different approach in doing literally the same things. So here I’d like to list out what piqued 
my curiosity:</p>

<p><strong>Event Handling</strong></p>

<p>In React, event handlers are functions passed from parent to child; or if you are using Redux you pass from a smart to dumb components.</p>

<div class="language-javascript highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="kd">const</span> <span class="nx">handler</span> <span class="o">=</span> <span class="nx">event</span> <span class="o">=&gt;</span> <span class="p">{</span> <span class="cm">/* do something */</span> <span class="p">}</span>
<span class="k">export</span> <span class="k">default</span> <span class="p">(</span><span class="nx">props</span><span class="p">)</span> <span class="o">=&gt;</span> <span class="p">{</span>
  <span class="o">&lt;</span><span class="nx">SomeComponent</span> <span class="nx">clickHandler</span><span class="o">=</span><span class="p">{</span><span class="nx">handler</span><span class="p">}</span> <span class="sr">/</span><span class="err">&gt;
</span><span class="p">}</span>
</code></pre></div></div>
<p>In Vue however, I like that component actions are emitted and a parent component reacts to a event.</p>
<div class="language-javascript highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c1">// Child Component</span>
<span class="nx">Vue</span><span class="p">.</span><span class="nx">component</span><span class="p">(</span><span class="dl">'</span><span class="s1">child-component</span><span class="dl">'</span><span class="p">,</span> <span class="p">{</span>
  <span class="na">methods</span><span class="p">:</span> <span class="p">{</span>
    <span class="nx">excitingEvent</span><span class="p">()</span> <span class="p">{</span>
      <span class="k">this</span><span class="p">.</span><span class="nx">$emit</span><span class="p">(</span><span class="dl">'</span><span class="s1">woah</span><span class="dl">'</span><span class="p">)</span>
    <span class="p">}</span>
  <span class="p">}</span>
<span class="p">})</span>
</code></pre></div></div>
<div class="language-javascript highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c1">// Parent Template</span>
<span class="o">&lt;</span><span class="nx">child</span><span class="o">-</span><span class="nx">component</span> <span class="nx">v</span><span class="o">-</span><span class="nx">on</span><span class="p">:</span><span class="nx">woah</span><span class="o">=</span><span class="dl">"</span><span class="s2">reactionMethod</span><span class="dl">"</span><span class="o">/&gt;</span>
</code></pre></div></div>
<p>It’s not that different with React, but in my mind this is much easier to understand. Because it explicitly tells you just by looking at it 
that an event is being reacted to by the parent, not unlike in React where behavior is passed on to a child.</p>

<p><strong>Computed Properties</strong></p>

<p>There are some things that you need to be evaluated before you use it in a view. Say, removing a few keys from an object, transforming text, 
you get the idea. <a href="https://vuejs.org/v2/guide/computed.html">Computed Properties</a> in Vue act like regular properties but it passes through a
function whenever a re-render occurs.</p>

<figure class="highlight"><pre><code class="language-javascript" data-lang="javascript"><span class="nx">Vue</span><span class="p">.</span><span class="nx">component</span><span class="p">(</span><span class="dl">'</span><span class="s1">lol</span><span class="dl">'</span><span class="p">,</span> <span class="p">{</span>
  <span class="na">data</span><span class="p">:</span> <span class="p">{</span> <span class="na">message</span><span class="p">:</span> <span class="dl">'</span><span class="s1">i am so angry</span><span class="dl">'</span> <span class="p">}</span>
  <span class="nl">computed</span><span class="p">:</span> <span class="p">{</span>
    <span class="na">angryMessage</span><span class="p">:</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
      <span class="k">return</span> <span class="s2">`</span><span class="p">${</span><span class="k">this</span><span class="p">.</span><span class="nx">message</span><span class="p">}</span><span class="s2">!!!!`</span><span class="p">.</span><span class="nx">toUpperCase</span><span class="p">()</span>
    <span class="p">}</span>
  <span class="p">}</span>
<span class="p">})</span></code></pre></figure>

<figure class="highlight"><pre><code class="language-html" data-lang="html"><span class="nt">&lt;p&gt;</span>{{ angryMessage }}<span class="nt">&lt;/p&gt;</span>
// =&gt; I AM SO ANGRY!!!!</code></pre></figure>

<p><em>All caps make you look angry!!!!</em></p>

<h3 id="wrapping-it-up">Wrapping it up!</h3>

<p>All in all, I enjoyed my time playing with Vue. It’s simple enough to learn in a few days, and full featured enough for large and complex
applications. It might be worth considering Vue as a front-end framework of choice for your next project. You can check out the source code of
<a href="http://github.com/kendaganio/jkbx">jkbx at Github</a> and you can play with it at <a href="https://kendaganio.com/jkbx">https://kendaganio.com/jkbx</a>.</p>]]></content><author><name></name></author><category term="software-development" /><category term="vue" /><category term="angular" /><category term="personal-projects" /><summary type="html"><![CDATA[The framework Vue has constantly been flashing in my radar as a new shiny thing to learn. I was still busy upping my React game and had no opportunity to learn new stuff (read: I’m a fucking slob). But as a resolution of sorts I want to commit code at least once a day. This sets up a good excuse to learn Vue!]]></summary></entry><entry><title type="html">New year, new me and all that nonsense.</title><link href="https://kendaganio.com/2018/01/25/new-year-new-me-and-all-that-nonsense" rel="alternate" type="text/html" title="New year, new me and all that nonsense." /><published>2018-01-25T00:00:00+00:00</published><updated>2018-01-25T00:00:00+00:00</updated><id>https://kendaganio.com/2018/01/25/new-year-new-me-and-all-that-nonsense</id><content type="html" xml:base="https://kendaganio.com/2018/01/25/new-year-new-me-and-all-that-nonsense"><![CDATA[<p>Ah yes, the start of the year. The advent of transformation, new beginnings, wilder and more unattainable dreams.
As you look back through your goals for last year, you’re glad to see that at least one of your fifty
has been ticked off. You pat yourself on the back, and let out a “Well done!” under your breath.
You smile in a condescending kind of way. You retreat back to your comfortable chair, and a single tear drops.</p>

<p>I’m sure this is relatable to the majority of us. I, like most people suffer from the dreaded curse of procastination.
This year I will attempt something unimaginable. I will be productive almost everyday. Who am I kidding, right? But first, metrics.</p>

<p>Truly for a goal to be attainable it should at least be measurable. Not wanting to get ahead of myself, I will try to set
the smallest goals I can possibly attain and potentially grow from there. Here’s what I have in mind.</p>

<ol>
  <li>One commit per day</li>
  <li>Document what I have learned in writing</li>
  <li>Exercise twice a week</li>
  <li>Read 12 books this year</li>
</ol>

<p>For the 10x people out there, these goals seems lackluster; but I digress. In my experience shooting for the moon is 
counterproductive. When I see a gargantuan task I easily get demotivated by the sheer amount of work it entails. In light of this,
I have designed my goals to be puny. In the hopes that by tackling a small task a day motivates me to do more things. For this attempt
I will chronicle my progress in this blog and meticuluosly measure what I have done for a particular period. To be held 
accountable motivates more than just blind execution for achieving arbitrary goals, if that makes any sense.</p>

<p>I treat this post as a declaration. A clear and concise declaration of intent. God help me, for I might have bitten more than I can 
chew. I have really small teeth.</p>]]></content><author><name></name></author><category term="self" /><category term="personal-development" /><summary type="html"><![CDATA[Ah yes, the start of the year. The advent of transformation, new beginnings, wilder and more unattainable dreams. As you look back through your goals for last year, you’re glad to see that at least one of your fifty has been ticked off. You pat yourself on the back, and let out a “Well done!” under your breath. You smile in a condescending kind of way. You retreat back to your comfortable chair, and a single tear drops. I’m sure this is relatable to the majority of us. I, like most people suffer from the dreaded curse of procastination. This year I will attempt something unimaginable. I will be productive almost everyday. Who am I kidding, right? But first, metrics.]]></summary></entry></feed>