<?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: Jaime González García</title>
    <description>The latest articles on DEV Community by Jaime González García (@vintharas).</description>
    <link>https://dev.to/vintharas</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%2F93147%2F09d69d89-7e27-4285-86cc-d620dfcd20ec.jpg</url>
      <title>DEV Community: Jaime González García</title>
      <link>https://dev.to/vintharas</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/vintharas"/>
    <language>en</language>
    <item>
      <title>Practice Happiness</title>
      <dc:creator>Jaime González García</dc:creator>
      <pubDate>Fri, 18 Dec 2020 13:31:01 +0000</pubDate>
      <link>https://dev.to/vintharas/practice-happiness-2c61</link>
      <guid>https://dev.to/vintharas/practice-happiness-2c61</guid>
      <description>&lt;p&gt;&lt;em&gt;This article was originally published at &lt;a href="https://www.barbarianmeetscoding.com" rel="noopener noreferrer"&gt;Barbarian Meets Coding&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;I've been diving a lot into the science of happiness and contentment for the past months as I prepare for our second child. These are some things I've found useful.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Meditation
&lt;/h2&gt;

&lt;p&gt;I've been practicing meditation for about 5 years. I don't have a consistent practice, it comes and goes. Even so, meditation has helped me be more patient with my son Teo, my wife Malin and with all the struggles of parenting. Meditation has improved how I treat myself and other humans, cultivating empathy, reflection and improving my self-awareness.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A great boon of meditation is that it creates space between action and reaction&lt;/strong&gt;, between something happening around me, or to me and me reacting to it. That space is great to make better decisions on how to react to things and to learn to know myself. &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%2Fwww.barbarianmeetscoding.com%2Fimages%2Faction-reaction.jpg" 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%2Fwww.barbarianmeetscoding.com%2Fimages%2Faction-reaction.jpg" title='Action -&amp;gt; Reaction" alt="Action -&amp;gt; Reaction"&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p style='&gt;&lt;/a&gt;&lt;em&gt;&lt;/em&gt;&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%2Fwww.barbarianmeetscoding.com%2Fimages%2Faction-space-reaction.jpg" 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%2Fwww.barbarianmeetscoding.com%2Fimages%2Faction-space-reaction.jpg" title='Action -&amp;gt; Space -&amp;gt; Reaction" alt="Action -&amp;gt; Space -&amp;gt; Reaction"&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p style='&gt;&lt;/a&gt;&lt;em&gt;Meditation creates space between action and reaction.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;As my son throws a tantrum for the 4th time this morning, I can see my anger and irritation rise within me and choose to be patient, because I know that patience and being calm are far better tools to take care of a 3 year old than anger and shouting. Without meditation, I'm far more likely to have my anger bubble out making everything worse. &lt;/p&gt;

&lt;p&gt;Likewise meditation makes me aware of feelings and thoughts as I experience the world. As I feel anger, irritation or discomfort about a person or situation at work, I can take a mental note, understand the source of those thoughts and feelings, and prevent them from taking the better of me. Sometimes, I'll find that the mere act of taking a mental note of a feeling &lt;em&gt;"I'm angry"&lt;/em&gt; has the power to dispel that very feeling (which is nuts, but it works).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="http://headspace.com" rel="noopener noreferrer"&gt;Headspace&lt;/a&gt; is a great place to start meditating&lt;/strong&gt;. It's beautiful and extremely beginner friendly.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://www.amazon.com/gp/product/B004TTHD9O" rel="noopener noreferrer"&gt;Mindfulness, a practical guide to finding peace in a frantric world&lt;/a&gt; was the book that got me into meditation in 2015. That's a nice way to get into meditation if you enjoy reading books.&lt;/p&gt;
&lt;h2&gt;
  
  
  2. Exercise
&lt;/h2&gt;

&lt;p&gt;Super basic, but &lt;strong&gt;there's no bad mood that going for a walk can't fix&lt;/strong&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Low on morale =&amp;gt; exercise
Low on energy =&amp;gt; exercise
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Can't find energy to exercise?&lt;/strong&gt; Start with 5 minutes. Anyone can do 5 minutes of anything.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Can't do 5 minutes?&lt;/strong&gt; Do 1 minute.&lt;/p&gt;

&lt;p&gt;is &lt;strong&gt;go exercise&lt;/strong&gt; too vague of an advice? Do this:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;If you aren't much for sports or exercise, start by taking brisk walks. Any length works. You'll find yourself taking longer walks than you expected because they're enjoyable. You can be present and enjoy nature, or talk to a friend, or listen to an audiobook, podcast or music.&lt;/li&gt;
&lt;li&gt;The next step is doing &lt;a href="https://en.wikipedia.org/wiki/High-intensity_interval_training" rel="noopener noreferrer"&gt;HIIT&lt;/a&gt; or High Intensity Interval Training. This is good for you heart, your metabolism and your brain. Anything that rises your heartbeat is good for you. Don't know where to start? Try &lt;a href="https://www.freeletics.com/" rel="noopener noreferrer"&gt;Freeletics&lt;/a&gt;. They have lots of free workouts that you can do without any equipment. If you haven't done much exercise before, take it easy at first.&lt;/li&gt;
&lt;li&gt;Then combine it with &lt;a href="https://en.wikipedia.org/wiki/Strength_training" rel="noopener noreferrer"&gt;strength training&lt;/a&gt; by lifting weights and incrementally increasing the weight over time as you get more fit. Strength training increases your strength, develops muscles, increases bone density, flexibility and combats aging. &lt;a href="https://amzn.to/2J4bV0o" rel="noopener noreferrer"&gt;Bigger, leaner, stronger&lt;/a&gt; is a great book to get started with strength training.&lt;/li&gt;
&lt;/ol&gt;

&lt;blockquote&gt;
&lt;p&gt;Adults who engage in leisure time aerobic and muscle strengthening activities show greatly reduced risk of all cause and cause specific mortality.&lt;/p&gt;

&lt;p&gt;&lt;cite&gt;&lt;a href="https://www.bmj.com/content/370/bmj.m2031" rel="noopener noreferrer"&gt;Recommended physical activity and all cause and cause specific mortality in US adults: prospective cohort study&lt;br&gt;
&lt;/a&gt;&lt;/cite&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;At the end of the day, if you can find a form of exercise that you enjoy, rises your heartbeat and you can do consistently you're doing great.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Journaling
&lt;/h2&gt;

&lt;p&gt;Journaling, the habit of writing down your daily experiences and thoughts, helps me develop more self-awareness, and creates a space and time for me to talk to myself. It's a very peaceful and enjoyable activity.&lt;/p&gt;

&lt;p&gt;Journaling is something that had been repeatedly recommended to me but I never got around to doing. Oddly enough, the breakthrough for me was reading Jordan Mechner's own journal on &lt;a href="https://amzn.to/3ah3cmy" rel="noopener noreferrer"&gt;The Making of Prince of Persia&lt;/a&gt;. By reading his words, his thoughts about graduating from university and coming of age, his hopes for the future, his struggles when choosing between a career in game development and film making, his writing about trivial daily things... it finally clicked. And so I started journaling and it's been a wonderful experience. You should try it too. And if you're lacking inspiration. Try reading &lt;a href="https://amzn.to/3ah3cmy" rel="noopener noreferrer"&gt;The Making of Prince of Persia&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tip:&lt;/strong&gt; Get a real good notebook and a real good pen. It gives you that additional visceral joy in the mere act of putting pen to paper. &lt;a href="https://www.baronfig.com/" rel="noopener noreferrer"&gt;Baronfig&lt;/a&gt; are the ones I use, and they are awesome.&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%2Fwww.barbarianmeetscoding.com%2Fimages%2Fjaimes-baronfig-notebook.jpg" 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%2Fwww.barbarianmeetscoding.com%2Fimages%2Fjaimes-baronfig-notebook.jpg" title="My notebook!" alt="The first page of a baronfig notebook and a blue pen. There's a note that says: This is Jaime's notebook of awesome and quirky notes."&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Gratitude
&lt;/h2&gt;

&lt;p&gt;I combine gratitude with my journaling. It helps me focus in the things that I appreciate in life and to cultivate appreciation. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;No matter how shitty my day has been, there is at least one thing I'm sure to be grateful about.&lt;/strong&gt; (plot twist: There's more than one. The more you cultivate appreciation the easier it is to find the good in life.)&lt;/p&gt;

&lt;p&gt;If you don't know where to start, just write down one thing you are grateful for every night before going to bed. If you already have a habit of journaling, or taking notes while planning your day, a great way to start a habit of gratitude is to take that time to write what you are grateful for. (This technique is known as &lt;a href="https://jamesclear.com/habit-stacking" rel="noopener noreferrer"&gt;habit stacking&lt;/a&gt; and is a great way to take advantage of existing habits to develop new ones).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://amzn.to/3ao7RmT" rel="noopener noreferrer"&gt;The little book of Gratitude&lt;/a&gt; is a short and super cute book that you can use to cultivate more gratitude.&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%2Fi%2F91p6pli5ccklp987g2qe.jpg" 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%2Fi%2F91p6pli5ccklp987g2qe.jpg" title="The Little Book of Gratitude" alt="The Little Book of Gratitude"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Investing in your strengths
&lt;/h2&gt;

&lt;p&gt;This was something I learned in &lt;a href="https://www.coursera.org/learn/the-science-of-well-being" rel="noopener noreferrer"&gt;The Science of Well-being&lt;/a&gt;. A course about increasing your happiness that Laurie (from &lt;a href="https://www.happinesslab.fm/" rel="noopener noreferrer"&gt;The Happiness Lab&lt;/a&gt;) does at Yale. The tl;dr is that you are happier if you spend time doing things that you enjoy doing, that play to your character strengths 😅 (doh)&lt;/p&gt;

&lt;p&gt;In the hecticness of life it is easy to come out of contact with this basic principle. We very easily fall into the daily grind, and start focusing more in what it is expected of us and what others need from us that we get out of touch with our own needs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Do you know what makes you happy? Can you carve some time for it in your day to day?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you aren't fully aware of your character strengths or you have never stopped to think about it, there's a &lt;a href="//viacharacter.org/survey"&gt;free survey&lt;/a&gt; that is a great way to get some ideas.&lt;/p&gt;

&lt;p&gt;These are mine:&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%2Fwww.barbarianmeetscoding.com%2Fimages%2Fcharacter-strengths.jpeg" 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%2Fwww.barbarianmeetscoding.com%2Fimages%2Fcharacter-strengths.jpeg" title="These are my top 5 character strengths" alt="A list of character strengths: love, curiosity, humility, appreciation and love of learning"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I've learned that if I spend some of my day doing any of those things I feel happier and more content. Even doing one thing, for as short as 30 minutes counts. For example, I'm super curious and love learning new stuff. If I block 30 minutes or less to learn something new, I feel a profound sense of contentment that accompanies me for the rest of the day.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Sleep
&lt;/h2&gt;

&lt;p&gt;Sleep should probably be at the top of this list. It is the one thing whose lack of makes the most difference in your energy and mood levels. Yet it is so easy to trade hours of sleep for anything else. You may trade hours for getting ahead in your career, or to play video games and watch series. There's also something called &lt;a href="https://greatist.com/discover/revenge-bedtime-procrastination" rel="noopener noreferrer"&gt;revenge bedtime procrastination&lt;/a&gt;, a phenomenon in which people who don’t feel in control over their daytime life refuse to go to sleep so that they can regain a sense of freedom and control during late night hours. This is me as a parent. Night time is pretty much the only time of the day where I feel I can get some me-time. And I bet that there are a lot of people out there in the same situation as me.&lt;/p&gt;

&lt;p&gt;The problem is that continuously trading sleep at night for doing other things is an evil circle where you progressively become more tired, more irritable, until you get to a point where you are so exhausted that you can't enjoy life. You aren't even present. You are a husk. And that's no way to live. Therefore get some sleep.&lt;/p&gt;

&lt;p&gt;It is very easy to go around tired or even exhausted and not realize you aren't sleeping enough. Devices like smart watches or a fitbit are great tools to help you realize how little you sleep and/or exercise. They put a number on it, they bring it to your attention and they nudge you ever so slightly towards doing something about it.&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%2Fwww.barbarianmeetscoding.com%2Fimages%2Ffitbit.jpeg" 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%2Fwww.barbarianmeetscoding.com%2Fimages%2Ffitbit.jpeg" title="Fitbit is a great device that nudges you towards exercise and sleep" alt="My fitbit"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A great book to learn more about the importance of sleep is &lt;a href="https://amzn.to/37u3ZyF" rel="noopener noreferrer"&gt;Why we Sleep: Unlocking the Power of sleep and dreams&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where can I Learn More?
&lt;/h2&gt;

&lt;p&gt;So that's it! Hope you can use any of these tricks to have a more fulfilling and content life! &lt;/p&gt;

&lt;p&gt;Here's a couple of places that you can use to continue your journey:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://www.happinesslab.fm/" rel="noopener noreferrer"&gt;The Happiness Lab&lt;/a&gt;. A really great podcast about the science of happiness that you can start listening to in your next brisk walk. Do it. Right now! :)&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.coursera.org/learn/the-science-of-well-being" rel="noopener noreferrer"&gt;The Science of Well-being&lt;/a&gt; is a free course that teaches you a lots of the theory behind the science of well-being (how bad we are at predicting the things that will make us happy, what things do really make us happy, etc...) and a bunch of practices like the ones detailed above to help you live a happier life.&lt;/li&gt;
&lt;/ul&gt;

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

&lt;p&gt;&lt;strong&gt;This article started as a &lt;a href="https://twitter.com/Vintharas/status/1338038400138489856" rel="noopener noreferrer"&gt;twitter thread&lt;/a&gt;, if you find it useful and want more, &lt;a href="https://twitter.com/Vintharas" rel="noopener noreferrer"&gt;find me on twitter&lt;/a&gt;.&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>inspiration</category>
      <category>reflection</category>
      <category>happiness</category>
    </item>
    <item>
      <title>Learn Vim. A new extension to help you learn Vim in VSCode</title>
      <dc:creator>Jaime González García</dc:creator>
      <pubDate>Sat, 05 Sep 2020 13:45:51 +0000</pubDate>
      <link>https://dev.to/vintharas/learn-vim-a-new-plugin-to-help-you-learn-vim-in-vscode-kn9</link>
      <guid>https://dev.to/vintharas/learn-vim-a-new-plugin-to-help-you-learn-vim-in-vscode-kn9</guid>
      <description>&lt;p&gt;As I was writing &lt;a href="https://www.javascriptmancy.com/" rel="noopener noreferrer"&gt;JavaScriptmancy&lt;/a&gt;, &lt;a href="https://www.barbarianmeetscoding.com/boost-your-coding-fu-with-vscode-and-vim/" rel="noopener noreferrer"&gt;Boost Your Coding Fu with VSCode and Vim&lt;/a&gt; and &lt;a href="https://www.wizardsusevim.com/" rel="noopener noreferrer"&gt;Wizards Use Vim&lt;/a&gt; I've always envisioned a more interactive way to teach through practice, play and games. Life happens and I sort of got as far as writing but never much further. I left those cool ideas of interactive learning, roguelikes, RPG-esque JavaScript, Vim platformers archived somewhere at the bottom of bottomless TODO lists, half-remembered thoughts and someday/maybes...&lt;/p&gt;

&lt;p&gt;But yesterday as I was preparing breakfast I wondered... Hmm could I write a VSCode extension to help people learn Vim in VSCode? Could I do it in just one day? And it turns out I can... Sort of&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Behold!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://marketplace.visualstudio.com/items?itemName=vintharas.learn-vim" rel="noopener noreferrer"&gt;Learn Vim&lt;/a&gt;&lt;/strong&gt;, a VSCode extension that helps you learn Vim right within VSCode, keeps your progress and provides room for thoughtful reading and deliberate practice (and soon games?).&lt;/p&gt;

&lt;p&gt;Open Visual Studio, install &lt;em&gt;Learn Vim&lt;/em&gt; like any other extension and then:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Open the command palette&lt;/li&gt;
&lt;li&gt;Type &lt;em&gt;Learn Vim&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;Victory&lt;/li&gt;
&lt;/ol&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%2Fwww.barbarianmeetscoding.com%2Fimages%2Flearn-vim.jpg" 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%2Fwww.barbarianmeetscoding.com%2Fimages%2Flearn-vim.jpg" alt="Learn Vim"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Hope you find it useful! And don't hesitate to give me a shout, ask me a question or let me know what you think. Have fun! And may the Elder Gods of Vim always be with you.&lt;/p&gt;

</description>
      <category>showdev</category>
      <category>vscode</category>
      <category>vim</category>
      <category>webdev</category>
    </item>
    <item>
      <title>TypeScript Types Deep Dive - The Talk</title>
      <dc:creator>Jaime González García</dc:creator>
      <pubDate>Sun, 07 Jun 2020 15:38:32 +0000</pubDate>
      <link>https://dev.to/vintharas/typescript-types-deep-dive-the-talk-3amp</link>
      <guid>https://dev.to/vintharas/typescript-types-deep-dive-the-talk-3amp</guid>
      <description>&lt;p&gt;Learn more about the wondrous and mysterious world of the TypeScript type system, this time condensed into an exciting, fun and insightful talk by yours truly. Enjoy!&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/ThLVga4oKRw"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
      <category>typescript</category>
      <category>javascript</category>
      <category>webdev</category>
    </item>
    <item>
      <title>5 Minutes Vim: Copying, Cutting, Pasting, Registers, and How to Tame Them</title>
      <dc:creator>Jaime González García</dc:creator>
      <pubDate>Sat, 01 Feb 2020 22:02:54 +0000</pubDate>
      <link>https://dev.to/vintharas/5-minutes-vim-copying-cutting-pasting-registers-and-how-to-tame-them-5703</link>
      <guid>https://dev.to/vintharas/5-minutes-vim-copying-cutting-pasting-registers-and-how-to-tame-them-5703</guid>
      <description>&lt;p&gt;&lt;em&gt;This article was originally posted in &lt;a href="https://www.barbarianmeetscoding.com/blog/2020/02/01/5-minutes-vim-copy-pasting-and-registers"&gt;barbarianmeetscoding.com&lt;/a&gt;. Sorry for the long 5 minutes-ish. 😊&lt;/em&gt; &lt;/p&gt;

&lt;p&gt;In this 5 minutes of Vim goodness we'll learn how to effectively copy, cut and paste things in Vim by taking advantage of Vim registers and a cool plugin. Here we go!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Copy and paste&lt;/strong&gt;. Doesn't sound like much excitement, does it? You are probably accustomed to use your mouse to perform some text selection, copy or cut it and then paste it somewhere else. And that is it. Not so much to be excited about.&lt;/p&gt;

&lt;p&gt;Vim spices up copying, cutting and pasting in a couple of ways:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;It gives you new shiny operators and commands you can use in combination with all the motions you've learn thus far&lt;/li&gt;
&lt;li&gt;It provides a handful of registers where you can save stuff for later pasting which can enable interesting workflows&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The two main commands for copying and pasting are &lt;code&gt;y&lt;/code&gt; and &lt;code&gt;p&lt;/code&gt;. &lt;em&gt;Why &lt;code&gt;y&lt;/code&gt; and not &lt;code&gt;c&lt;/code&gt; for **c&lt;/em&gt;&lt;em&gt;opy, you may wonder?&lt;/em&gt; Well, if you are familiar with Vim you may know that &lt;code&gt;c&lt;/code&gt; is already taken, it is the change command. And thus, the vi engineers had to come up with a suitable way to describe copying and settled on the colourful name of &lt;strong&gt;y&lt;/strong&gt;ank (because engineers are far more playful than one would think at first sight). So in Vim you don't copy stuff, you &lt;strong&gt;yank&lt;/strong&gt; it (great naming... So visceral). &lt;code&gt;p&lt;/code&gt; stands for &lt;strong&gt;p&lt;/strong&gt;ut and therefore in Vim you yank some text from somwhere and put it some place else. If you're accustomed to think of &lt;code&gt;p&lt;/code&gt; in terms of pasting then feel free to use whichever mnemonic makes you happy.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;From now on, instead of copy I'll say &lt;strong&gt;yank&lt;/strong&gt; so you get accustomed to it and can easily connect it in your brain and muscle memory to the letter &lt;code&gt;y&lt;/code&gt;. Yank! Yank! Yank!&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;y&lt;/code&gt; is an operator&lt;/strong&gt;. You can combine it with any of the motions and text-objects we've learned to yank stuff to your heart's content:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;yl&lt;/code&gt;&lt;/strong&gt; &lt;strong&gt;y&lt;/strong&gt;anks a &lt;strong&gt;l&lt;/strong&gt;etter,&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;yaw&lt;/code&gt;&lt;/strong&gt; &lt;strong&gt;y&lt;/strong&gt;anks a &lt;strong&gt;w&lt;/strong&gt;ord, &lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;yas&lt;/code&gt;&lt;/strong&gt; &lt;strong&gt;y&lt;/strong&gt;anks a &lt;strong&gt;s&lt;/strong&gt;entence&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;yi(&lt;/code&gt;&lt;/strong&gt; &lt;strong&gt;y&lt;/strong&gt;anks everything within &lt;strong&gt;&lt;code&gt;(&lt;/code&gt;&lt;/strong&gt; and so on...&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you double &lt;code&gt;y&lt;/code&gt; as in &lt;code&gt;yy&lt;/code&gt; you get &lt;strong&gt;a linewise operator&lt;/strong&gt; like &lt;code&gt;dd&lt;/code&gt; and &lt;code&gt;cc&lt;/code&gt; and yank a whole line. The &lt;code&gt;Y&lt;/code&gt; command also yanks a complete line.&lt;/p&gt;

&lt;p&gt;In order to paste things you use the &lt;code&gt;p&lt;/code&gt; command and its variants:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;p&lt;/code&gt; pastes something after the cursor&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;P&lt;/code&gt; pastes something before the cursor&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;gp&lt;/code&gt; same as &lt;code&gt;p&lt;/code&gt; but puts the cursor after the pasted selection&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;gP&lt;/code&gt; same as &lt;code&gt;P&lt;/code&gt; and puts the cursor after the pasted selection&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Pasting in Vim is kind of special and the behavior of &lt;code&gt;p&lt;/code&gt; and &lt;code&gt;P&lt;/code&gt; depend on whether you've yanked characters or lines. If you've yanked &lt;strong&gt;characters&lt;/strong&gt; then pasting will put those characters after or before the cursor (no surprises there). If you've yanked &lt;strong&gt;lines&lt;/strong&gt;, however, pasting will put those lines after or before the line where the cursor is resting on. This behavior may sound weird at first but it makes a lot of sense in practice.&lt;/p&gt;

&lt;p&gt;Imagine that you are contemplating this powerful extract from an ancient text:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Hither came Conan, the Cimmerian, black-haired, sullen-eyed, sword in hand, a thief, a reaver, a slayer, with gigantic melancholies and gigantic mirth, to tread the jeweled thrones of the Earth under his sandaled feet.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And you want to add more intensity to this passage you may decide to &lt;strong&gt;yank&lt;/strong&gt; the &lt;code&gt;the&lt;/code&gt; particle and sprinkle it here and there:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;v
Hither came Conan, the Cimmerian, black-haired, sullen-eyed, ...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Start by jumping to the &lt;em&gt;the&lt;/em&gt; particle with &lt;code&gt;f,w&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;       v                  v
f,w    Hither came Conan, the Cimmerian, black-haired, ...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then yank the word with &lt;code&gt;yaw&lt;/code&gt;, jump to the next location were to put &lt;em&gt;the&lt;/em&gt; with &lt;code&gt;;w&lt;/code&gt; and paste with &lt;code&gt;P&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;                         v                 v
;w    Hither came Conan, the Cimmerian, the black-haired, ...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The jump to the next location again with &lt;code&gt;;w&lt;/code&gt; and type &lt;code&gt;.&lt;/code&gt; to repeat the last change:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Hither came Conan, the Cimmerian, the black-haired, the sullen-eyed, ...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Want to duplicate a line instead?&lt;/strong&gt; It is as easy as typing &lt;code&gt;yyp&lt;/code&gt;. Imagine that you have an array literal in JavaScript and it's filled with magical items of wonder:&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;chest&lt;/span&gt; &lt;span class="o"&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;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;sword&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;weight&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;2.1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;state&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;well kept&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="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;rusty dagger&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;weight&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;state&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;worn out&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And now you want to add some more items to this chest. You can use any of the existing items as a template and type &lt;code&gt;yyp&lt;/code&gt; to duplicate it:&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;chest&lt;/span&gt; &lt;span class="o"&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;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;sword&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;weight&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;2.1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;state&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;well kept&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="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;rusty dagger&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;weight&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;state&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;worn out&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="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;rusty dagger&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;weight&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;state&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;worn out&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then type &lt;code&gt;ci'&lt;/code&gt; to change its name to something else:&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;chest&lt;/span&gt; &lt;span class="o"&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;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;sword&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;weight&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;2.1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;state&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;well kept&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="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;rusty dagger&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;weight&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;state&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;worn out&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="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;scepter of fire&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;weight&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;state&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;worn out&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Want to n-plicate a line?&lt;/em&gt; (Yes, I'm pretty sure that's a real word) It is as simple as typing &lt;code&gt;yy{count}p&lt;/code&gt;. &lt;strong&gt;Yes! Counts also work with yank and pasting because they're just commands!&lt;/strong&gt; Let's retry the example above but this time type &lt;code&gt;yy5p&lt;/code&gt;:&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;chest&lt;/span&gt; &lt;span class="o"&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;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;sword&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;weight&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;2.1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;state&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;well kept&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="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;rusty dagger&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;weight&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;state&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;worn out&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="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;rusty dagger&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;weight&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;state&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;worn out&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="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;rusty dagger&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;weight&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;state&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;worn out&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="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;rusty dagger&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;weight&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;state&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;worn out&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="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;rusty dagger&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;weight&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;state&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;worn out&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="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;rusty dagger&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;weight&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;state&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;worn out&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Wow! Impressive, isn't it?&lt;/p&gt;

&lt;p&gt;Ok. So if &lt;code&gt;y&lt;/code&gt;, the yank command, copies stuff... How do you cut things in Vim? &lt;strong&gt;Aha! Here comes a surprise!&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Cutting Stuff In Vim
&lt;/h2&gt;

&lt;p&gt;You may be familiar with the &lt;code&gt;d&lt;/code&gt; (delete) and &lt;code&gt;c&lt;/code&gt; (change) commands in Vim? As their name indicates they let you &lt;em&gt;delete&lt;/em&gt; and &lt;em&gt;change&lt;/em&gt; text in Vim. A lesser know fact is that, in addition to deleting and changing text, they also cut it.&lt;/p&gt;

&lt;p&gt;Imagine that in addition to the &lt;code&gt;chest&lt;/code&gt; we had earlier we now have a brave adventurer ready to explore the world and confront its perils. Sadly, our adventurer has little and lacks many of the tools of the adventuring trade she'll need to survive:&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;chest&lt;/span&gt; &lt;span class="o"&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;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;sword&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;weight&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;2.1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;state&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;well kept&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="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;rusty dagger&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;weight&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;state&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;worn out&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="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;rusty dagger&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;weight&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;state&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;worn out&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="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;sonja&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Sonja&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;inventory&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="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's give her some help and move the well kept sword from the chest into her inventory:&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;v&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;chest&lt;/span&gt; &lt;span class="o"&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;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;sword&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;weight&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;2.1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;state&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;well kept&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="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;rusty dagger&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;weight&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;state&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;worn out&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="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;rusty dagger&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;weight&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;state&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;worn out&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We type &lt;code&gt;2jdd&lt;/code&gt; to jump two lines down and delete (and cut) our sword:&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;chest&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
  &lt;span class="nx"&gt;v&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;rusty dagger&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;weight&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;state&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;worn out&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="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;rusty dagger&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;weight&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;state&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;worn out&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then &lt;code&gt;/in&amp;lt;ENTER&amp;gt;&lt;/code&gt; to move our cursor on to of the &lt;em&gt;in&lt;/em&gt; in &lt;code&gt;inventory&lt;/code&gt;:&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;sonja&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Sonja&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;v&lt;/span&gt;
  &lt;span class="na"&gt;inventory&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="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And now we type &lt;code&gt;p&lt;/code&gt; and we're ready for adventure:&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;sonja&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Sonja&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;inventory&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
  &lt;span class="nx"&gt;v&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;sword&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;weight&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;2.1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;state&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;well kept&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="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now you can save the file and if you have an autoformatter setup it'll fix your indentation or you can type &lt;code&gt;==&lt;/code&gt; to manually format that line.&lt;/p&gt;

&lt;p&gt;What more can you do with cutting and pasting in Vim? Have you ever made a typo and &lt;em&gt;need to swap two characters?&lt;/em&gt; Type &lt;code&gt;dlp&lt;/code&gt; (or &lt;code&gt;xp&lt;/code&gt;). &lt;em&gt;Want to swap couple of lines?&lt;/em&gt; Type &lt;code&gt;ddp&lt;/code&gt;. &lt;em&gt;Want to swap a couple of paragraphs?&lt;/em&gt; Type &lt;code&gt;dapp&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Excellent! So now you've boosted your knowledge with yanking, cutting and pasting in Vim. But there's yet one crucial element left that we haven't even touched on yet: &lt;strong&gt;The mighty registers&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;A wonderful way to illustrate the impact of registers is swapping two values within Vim. I do some variant of this task incredibly often.&lt;/p&gt;

&lt;p&gt;Imagine that you have a couple of CSS variables that represent a couple of colors in a color theme of a beautiful website you've just designed:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nd"&gt;:root&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="py"&gt;--red&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#0F0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;--green&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#F00&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;You quickly notice the colors are wrong. You've mixed them. The red is the green and the green is the red. Oh no! What to do!?&lt;/p&gt;

&lt;p&gt;So you try swapping them using what we've just learned. You type &lt;code&gt;/#&amp;lt;Enter&amp;gt;&lt;/code&gt; and put the cursor on top of the hexadecimal value:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;  &lt;span class="nt"&gt;--red&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="err"&gt;#0&lt;/span&gt;&lt;span class="nt"&gt;F0&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
         &lt;span class="o"&gt;^&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You cut it with &lt;code&gt;daW&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;  &lt;span class="nt"&gt;--red&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;
       &lt;span class="o"&gt;^&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Type &lt;code&gt;n&lt;/code&gt; to move to the next hex value, delete it with &lt;code&gt;daW&lt;/code&gt; and try to paste the red with &lt;code&gt;p&lt;/code&gt;, but...&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nd"&gt;:root&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="py"&gt;--red&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="n"&gt;--green&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#F00&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;&lt;strong&gt;What!?&lt;/strong&gt; That is so not what I expected to happen. What did I do wrong?&lt;/p&gt;

&lt;p&gt;You may have noticed the issue with this swap as you were following the example but if you haven't I will tell you: The problem is that &lt;strong&gt;delete&lt;/strong&gt; also cuts. When we deleted the hexadecimal value for the green color in the last step we literally overwrote the red hexadecimal value. That's why when we typed &lt;code&gt;p&lt;/code&gt; at the end the pasted characters where &lt;code&gt;#F00&lt;/code&gt; and not &lt;code&gt;#0F0&lt;/code&gt; as we initially expected.&lt;/p&gt;

&lt;p&gt;But what did we overwrite exactly? Most systems have the concept of a clipboard, which is a place where you put the stuff that you copy and cut. Well Vim doesn't have a clipboard, &lt;strong&gt;Vim has registers&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Vim Registers
&lt;/h2&gt;

&lt;p&gt;Vim registers are the equivalent of a clipboard, but since you have lots of them, they're that much powerful.&lt;/p&gt;

&lt;p&gt;When we use commands like &lt;code&gt;y&lt;/code&gt;, &lt;code&gt;d&lt;/code&gt;, &lt;code&gt;c&lt;/code&gt; and &lt;code&gt;p&lt;/code&gt; we're interacting with Vim's &lt;strong&gt;unnamed register&lt;/strong&gt;. You aren't limited to that one though, you have 26 &lt;strong&gt;named registers&lt;/strong&gt;, one for each letter of the alphabet, that you are free to use as you see fit. &lt;/p&gt;

&lt;p&gt;The way that you explicitly access a given register is by prefixing a command with &lt;code&gt;"[a-z]&lt;/code&gt;. So:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;"ayy&lt;/code&gt; yanks a line into the &lt;code&gt;a&lt;/code&gt; register&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;"add&lt;/code&gt; cuts a line into the &lt;code&gt;a&lt;/code&gt; register&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;"ap&lt;/code&gt; pastes from the &lt;code&gt;a&lt;/code&gt; register&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;Using the same pattern we can access the mysterious &lt;strong&gt;unnamed register&lt;/strong&gt; which does have a name after all. Its name is &lt;code&gt;"&lt;/code&gt; and you could replace &lt;code&gt;y&lt;/code&gt; for &lt;code&gt;""y&lt;/code&gt; if you had a fancy for writing more than you need to. But we won't do that.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Using the lowercase name of a named register overwrites its contents, whereas if we use the capitalized version of that name we will append whatever we yank or cut into the register (this can be really useful when we want to collect text into a register for later pasting).&lt;/p&gt;

&lt;p&gt;Using named registers offers one way to solve the problem that ailed us earlier when we were swapping colors. Instead of using the unnamed register alone we could've used it in combination with the &lt;code&gt;a&lt;/code&gt; register:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;code&gt;/#&amp;lt;Enter&amp;gt;&lt;/code&gt; to move the cursor to the first hex value&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;daW&lt;/code&gt; to cut the green color value in the unnamed register&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;n&lt;/code&gt;  to move to the second hex value&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;"adaW&lt;/code&gt; to cut it into the &lt;code&gt;a&lt;/code&gt; named register&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;p&lt;/code&gt; pastes the first hex value in the write place&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;k&lt;/code&gt; to go up&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;"ap&lt;/code&gt; which now pastes from the &lt;code&gt;a&lt;/code&gt; register and we're done&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Excellent! If you ever lose track about which register you have put stuff in, you can rely on the &lt;code&gt;:registers&lt;/code&gt; (or &lt;code&gt;:reg&lt;/code&gt;) command. &lt;code&gt;:registers&lt;/code&gt; will print the value of all registers into a buffer. If you're only interested in the contents of a particular register you can also specify it as an argument. For instance, typing &lt;code&gt;:reg a&lt;/code&gt; after the previous example would result in the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;--- Registers ---
"a    #F00;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Another useful way to interact with named registers is by taking advantage of the fact that capitalized named registers append to the register instead of replacing its contents. For instance, we could build an outline of a markdown document by continously appending headers to the &lt;code&gt;a&lt;/code&gt; register:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;/^#.*&amp;lt;ENTER&amp;gt;&lt;/code&gt; to jump to the next header&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;"ayy&lt;/code&gt; to copy the header into the &lt;code&gt;a&lt;/code&gt; register&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;n&lt;/code&gt; to jump to the next header&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;"Ayy&lt;/code&gt; to append the header to the contents of the &lt;code&gt;a&lt;/code&gt; register&lt;/li&gt;
&lt;li&gt;then &lt;code&gt;n&lt;/code&gt; and &lt;code&gt;"Ayy&lt;/code&gt; until you've gathered all the headers you want&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;"ap&lt;/code&gt; to paste the outline of the mardown document&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In addition to the named and unnamed registers there are more registers that will be useful from time to time: The &lt;strong&gt;yank  register&lt;/strong&gt; (&lt;code&gt;0&lt;/code&gt;), the &lt;strong&gt;delete registers&lt;/strong&gt; (&lt;code&gt;1-9&lt;/code&gt;) and the &lt;strong&gt;black hole register&lt;/strong&gt; (&lt;code&gt;_&lt;/code&gt;). &lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;yank register&lt;/strong&gt; &lt;code&gt;0&lt;/code&gt; holds the last bit of text you yanked. That is, it only stores text you have yanked with the &lt;code&gt;y&lt;/code&gt; command and lives completely unperturbed by whatever happens with cutting operations like &lt;code&gt;d&lt;/code&gt; or &lt;code&gt;c&lt;/code&gt;. This can be really useful if you want to rename a variable or other pieces of text. Using the yank register offers yet another alternative way to swap values.&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;delete registers&lt;/strong&gt; &lt;code&gt;1-9&lt;/code&gt; are nine registers that contain the last 9 pieces of text you cut or deleted. They work as a queue where every time you cut something it gets stuck in the queue at position &lt;code&gt;1&lt;/code&gt;, whatever was in &lt;code&gt;1&lt;/code&gt; is pushed to &lt;code&gt;2&lt;/code&gt; and so on. The delete register can be really useful when you happen to delete something in the past and you want to bring it back (in fact, it just saved me from losing a beautifully written parapraph). Just like the named and yank registers, you can take advantage of delete registers as an alternative way to swap values.&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;black hole&lt;/strong&gt; register has a fitting name because it truly allows you to delete text into oblivion. A nice way to avoid overwriting the unnamed register is to prefix the delete operator with the black hole register: For instance, type &lt;code&gt;"_daw&lt;/code&gt; to blast a word into oblivion for ever and ever.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;For a list of all registers available in Vim and how you can use them take a look at &lt;code&gt;:h registers&lt;/code&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Copy and Pasting In and Outside Of Vim
&lt;/h2&gt;

&lt;p&gt;Everything we've discussed thus far only applies to the world of Vim. All the commands and registers that we've seen allow you to yank, cut and paste text only within the confines of Vim. What happens when you want to copy to or paste from outside of Vim? For instance, when you find a wonderful piece of code on StackOverflow and want to try it in a program?&lt;/p&gt;

&lt;p&gt;There's two registers that work as an interface between Vim and the outside world: &lt;strong&gt;The &lt;code&gt;+&lt;/code&gt; and the &lt;code&gt;*&lt;/code&gt; registers&lt;/strong&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You can use the &lt;strong&gt;&lt;code&gt;+&lt;/code&gt;&lt;/strong&gt; register to interact with the system clipboard in Windows, Mac and Linux&lt;/li&gt;
&lt;li&gt;You can use the &lt;strong&gt;&lt;code&gt;*&lt;/code&gt;&lt;/strong&gt; register to interact with the primary clipboard in Linux, and also the system clipboard in Windows and Mac (since these two only have the single clipboard)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;One thing that I find super convenient and that I'd advise you to do is to have your system clipboard use the unnamed register. That way you can seamlessly copy and paste between Vim and the rest of your computer, taking advantage of the fastest commands &lt;code&gt;d&lt;/code&gt;, &lt;code&gt;c&lt;/code&gt;, &lt;code&gt;y&lt;/code&gt; and &lt;code&gt;p&lt;/code&gt;, and avoiding the need to specify the &lt;code&gt;+&lt;/code&gt; and &lt;code&gt;*&lt;/code&gt; registers.&lt;/p&gt;

&lt;p&gt;If you are using Neovim you can enable this behavior in your &lt;em&gt;vimrc&lt;/em&gt; like so:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight viml"&gt;&lt;code&gt;&lt;span class="k"&gt;set&lt;/span&gt; &lt;span class="nb"&gt;clipboard&lt;/span&gt;&lt;span class="p"&gt;+=&lt;/span&gt;unnamedplus " use &lt;span class="nb"&gt;system&lt;/span&gt; &lt;span class="nb"&gt;clipboard&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Likewise in traditional Vim:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight viml"&gt;&lt;code&gt;&lt;span class="k"&gt;set&lt;/span&gt; &lt;span class="nb"&gt;clipboard&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;unnamed " use &lt;span class="nb"&gt;system&lt;/span&gt; &lt;span class="nb"&gt;clipboard&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Take a look at &lt;code&gt;:h clipboard&lt;/code&gt; for more information.&lt;/p&gt;

&lt;h2&gt;
  
  
  Pasting in Insert mode
&lt;/h2&gt;

&lt;p&gt;All of this article has focused on how you can copy and paste things from within &lt;em&gt;Normal mode&lt;/em&gt;. Sometimes however, it can be helpful to paste things within &lt;em&gt;Insert mode&lt;/em&gt;. Earlier you learned how you can paste using the &lt;code&gt;p&lt;/code&gt; command but that won't do in &lt;em&gt;Insert mode&lt;/em&gt; (it would just insert the letter &lt;code&gt;p&lt;/code&gt;). What to do? Well, in some instances (f.i. gvim and mvim) you may be able to use your system copy/paste key bindings, but you can always rely on &lt;code&gt;&amp;lt;C-R&amp;gt;{register}&lt;/code&gt; to paste text from any given &lt;code&gt;register&lt;/code&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;&amp;lt;C-R&amp;gt;a&lt;/code&gt; pastes the contents of the &lt;code&gt;a&lt;/code&gt; register&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;&amp;lt;C-R&amp;gt;"&lt;/code&gt; pastes the contents of the unnamed register&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;&amp;lt;C-R&amp;gt;0&lt;/code&gt; pastes the contents of the yank register.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And yes, you've guessed it right, the &lt;code&gt;R&lt;/code&gt; stands for &lt;strong&gt;R&lt;/strong&gt;egister. Use that as a mnemnonic and you'll never forget how to paste things in &lt;em&gt;Insert mode&lt;/em&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  A Really Cool Plugin To Simplify Working With Registers in Vim
&lt;/h2&gt;

&lt;p&gt;Before we part here is a really cool plugin that helps you work with register in Vim: &lt;a href="https://github.com/junegunn/vim-peekaboo"&gt;vim-peekaboo&lt;/a&gt;. This plugin extends &lt;code&gt;"&lt;/code&gt; and &lt;code&gt;@&lt;/code&gt; in normal mode and &lt;code&gt;&amp;lt;CTRL-R&amp;gt;&lt;/code&gt; in insert mode so you can see the contents of the registers as you are about to perform a copying, cutting or pasting operation:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--uydWEETK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://cloud.githubusercontent.com/assets/700826/6095261/bb00340c-af96-11e4-9df5-9cd869673a11.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--uydWEETK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://cloud.githubusercontent.com/assets/700826/6095261/bb00340c-af96-11e4-9df5-9cd869673a11.gif" alt="A Vim user takes advantage of the peekaboo plugin to inspect what's inside their registers before pasting" title="vim-peekaboo" width="571" height="476"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Cool right?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;And that's all for today! Take care and have a wonderful day!&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>vim</category>
      <category>neovim</category>
    </item>
    <item>
      <title>Learn Svelte: Connecting the Pomodoro Timer and Tasks with Props and Stores</title>
      <dc:creator>Jaime González García</dc:creator>
      <pubDate>Tue, 28 Jan 2020 22:15:57 +0000</pubDate>
      <link>https://dev.to/vintharas/learn-svelte-connecting-the-pomodoro-timer-and-tasks-with-props-and-stores-p0k</link>
      <guid>https://dev.to/vintharas/learn-svelte-connecting-the-pomodoro-timer-and-tasks-with-props-and-stores-p0k</guid>
      <description>&lt;p&gt;&lt;em&gt;This article was originally published on &lt;a href="https://www.barbarianmeetscoding.com/blog/2020/01/28/learn-svelte-connecting-the-pomodoro-timer-and-tasks-with-props-and-stores"&gt;Barbarian Meets Coding&lt;/a&gt;. You can often find me there and on &lt;a href="https://twitter.com/vintharas"&gt;Twitter&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://svelte.dev/"&gt;Svelte&lt;/a&gt; is a modern web framework that takes a novel approach to building web applications by moving the bulk of its work from runtime to compile-time&lt;/strong&gt;. Being a compiler-first framework allows Svelte to do some very interesting stuff that is unavailable to other frameworks like disappearing from your application at runtime, or allowing for a component centered development with HTML, JavaScript and CSS coexisting within the same Svelte file in a very web standards friendly fashion.&lt;/p&gt;

&lt;p&gt;In this series we'll follow along as I use Svelte for the first time to build an app. I'll use my go-to project&lt;sup id="fnref1"&gt;1&lt;/sup&gt; to learn new frameworks: A &lt;a href="https://francescocirillo.com/pages/pomodoro-technique"&gt;Pomodoro Technique&lt;/a&gt; app, which is a little bit more involved than a TODO list in that it has at least a couple of components (a timer and a list of tasks) that need to interact with each other.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;In this part 5 of the series we finally put everything together and integrate the pomodoro with our collection of tasks. Yihoo! Let's get started!&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Haven't read the other articles in this series? Then you may want to take a look at this &lt;a href="https://www.barbarianmeetscoding.com/blog/2019/12/23/discovering-svelte"&gt;list of resources for getting started with Svelte&lt;/a&gt;, and the &lt;a href="https://www.barbarianmeetscoding.com/blog/2019/12/27/discovering-svelte-getting-started"&gt;first&lt;/a&gt;, &lt;a href="https://www.barbarianmeetscoding.com/blog/2019/12/29/discovering-svelte-adding-some-tasks-and-pomodoros"&gt;second&lt;/a&gt; and &lt;a href="https://www.barbarianmeetscoding.com/blog/2020/01/04/discovering-svelte-creating-a-pomodoro-timer"&gt;third&lt;/a&gt; parts of building the Pomodoro Technique app.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Pomodoro Meets Tasks
&lt;/h2&gt;

&lt;p&gt;So we have our pomodoro timer on one side, we have our list of tasks on the other. They are both living their lives independently as completely self-contained components. One can count down pomodoros, the other can manage a collection of tasks. Our next step to be able to support the Pomodoro technique is to get them to talk to each other so that a user can:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Select the tasks to focus on&lt;/li&gt;
&lt;li&gt;Start a pomodoro and focus fiercely on that task for 25 minutes&lt;/li&gt;
&lt;li&gt;Complete a pomodoro and take a rest&lt;/li&gt;
&lt;li&gt;Or cancel a pomodoro and type down the reason Why&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;But &lt;strong&gt;How can they talk to each other?&lt;/strong&gt; Either by sharing some state that can be passed between components through props, or by using a Svelte store.&lt;/p&gt;

&lt;p&gt;Let's implement both solutions and discuss the pros and cons of each of them.&lt;/p&gt;

&lt;h2&gt;
  
  
  Sharing State Through Props
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;h3&gt;
  
  
  What are Svelte props?
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;props&lt;/strong&gt; (short for &lt;em&gt;properties&lt;/em&gt;) are the mechanism that Svelte uses to send data into a component. In essence, &lt;strong&gt;props define the interface of a component. How it interacts with the outside world.&lt;/strong&gt;&lt;/p&gt;.
&lt;/blockquote&gt;

&lt;p&gt;So far in the series we've barely touched on props because both the Pomodoro Timer and the list of tasks have been self contained up to this point. Now however we need for both components to communicate. Specifically:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;We need the &lt;code&gt;TaskList&lt;/code&gt; component to be able to communicate with the outside world that a task has been selected&lt;/li&gt;
&lt;li&gt;We need to tell the &lt;code&gt;PomodoroTimer&lt;/code&gt; which task has been selected&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Selecting a Task
&lt;/h3&gt;

&lt;p&gt;So we start by updating our &lt;code&gt;TaskList&lt;/code&gt; component so that a user can select a task. We define a &lt;code&gt;selectedTask&lt;/code&gt; variable that will save that information:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;script&amp;gt;&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;activeTask&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="c1"&gt;// more code...&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And we update the template to select a task using a new button:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;{#if tasks.length === 0}
  &lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;You haven't added any tasks yet. You can do it! Add new tasks and start kicking some butt!&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
{:else}
  &lt;span class="nt"&gt;&amp;lt;ul&amp;gt;&lt;/span&gt;
    {#each tasks as task}
      &lt;span class="nt"&gt;&amp;lt;li&amp;gt;&lt;/span&gt;
        &lt;span class="c"&gt;&amp;lt;!-- NEW STUFF --&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;on:click=&lt;/span&gt;&lt;span class="s"&gt;{()&lt;/span&gt; &lt;span class="err"&gt;=&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt; selectTask(task)}&amp;gt;&lt;span class="ni"&gt;&amp;amp;gt;&lt;/span&gt;&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
        &lt;span class="c"&gt;&amp;lt;!--- END NEW STUFF --&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"description"&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"text"&lt;/span&gt; &lt;span class="na"&gt;bind:value=&lt;/span&gt;&lt;span class="s"&gt;{task.description}&lt;/span&gt; &lt;span class="na"&gt;bind:this=&lt;/span&gt;&lt;span class="s"&gt;{lastInput}&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"pomodoros"&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"number"&lt;/span&gt; &lt;span class="na"&gt;bind:value=&lt;/span&gt;&lt;span class="s"&gt;{task.expectedPomodoros}&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;on:click=&lt;/span&gt;&lt;span class="s"&gt;{()&lt;/span&gt; &lt;span class="err"&gt;=&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt; removeTask(task)}&amp;gt;X&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
    {/each}
  &lt;span class="nt"&gt;&amp;lt;/ul&amp;gt;&lt;/span&gt;
{/if}
&lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"primary"&lt;/span&gt; &lt;span class="na"&gt;on:click=&lt;/span&gt;&lt;span class="s"&gt;{addTask}&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Add a new task&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
{#if tasks.length != 0}
  &lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;
    Today you'll complete {allExpectedPomodoros} pomodoros.
  &lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
{/if}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now whenever the user clicks on the &lt;code&gt;&amp;gt;&lt;/code&gt; button we will call the &lt;code&gt;selectTask&lt;/code&gt; function that sets the activeTask to the selected task:&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;function&lt;/span&gt; &lt;span class="nx"&gt;selectTask&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;task&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;activeTask&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;task&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;And whenever a user removes a task we will check whether it is the &lt;code&gt;activeTask&lt;/code&gt; and in that case we will clean it up:&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;function&lt;/span&gt; &lt;span class="nx"&gt;removeTask&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;task&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
  &lt;span class="nx"&gt;tasks&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;tasks&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;remove&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;task&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;activeTask&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="nx"&gt;task&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;selectTask&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;undefined&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;Excellent! Now we need a way to tell the user that a given task is selected. We can do that by highlighting the active task using CSS. One way to achieve this is to set the &lt;code&gt;class&lt;/code&gt; attribute of the &lt;code&gt;li&lt;/code&gt; element to &lt;code&gt;.active&lt;/code&gt; like so:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;{#each tasks as task}
  &lt;span class="nt"&gt;&amp;lt;li&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;{activeTask&lt;/span&gt; &lt;span class="err"&gt;===&lt;/span&gt; &lt;span class="na"&gt;task&lt;/span&gt; &lt;span class="err"&gt;?&lt;/span&gt; &lt;span class="err"&gt;'&lt;/span&gt;&lt;span class="na"&gt;active&lt;/span&gt;&lt;span class="err"&gt;'&lt;/span&gt;&lt;span class="na"&gt;:&lt;/span&gt; &lt;span class="err"&gt;''}&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
     &lt;span class="c"&gt;&amp;lt;!-- task ---&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
{/each}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But Svelte has a shorthand syntax that makes it more convenient to add or remove classes based on your component's state:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;{#each tasks as task}
  &lt;span class="nt"&gt;&amp;lt;li&lt;/span&gt; &lt;span class="na"&gt;class:active=&lt;/span&gt;&lt;span class="s"&gt;{activeTask&lt;/span&gt; &lt;span class="err"&gt;===&lt;/span&gt; &lt;span class="na"&gt;task&lt;/span&gt;&lt;span class="err"&gt;}&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
     &lt;span class="c"&gt;&amp;lt;!-- task ---&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
{/each}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we need to add some styles linked to that &lt;code&gt;.active&lt;/code&gt; class inside the component:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;  &lt;span class="nc"&gt;.active&lt;/span&gt; &lt;span class="nt"&gt;input&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
  &lt;span class="nc"&gt;.active&lt;/span&gt; &lt;span class="nt"&gt;button&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;border-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--accent&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--accent&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="no"&gt;white&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;transition&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;background-color&lt;/span&gt; &lt;span class="m"&gt;.2s&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;color&lt;/span&gt; &lt;span class="m"&gt;.2s&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;border-color&lt;/span&gt; &lt;span class="m"&gt;.2s&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;And finally we have a way to select a task to work on within the &lt;code&gt;TaskList.svelte&lt;/code&gt; component:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Kd5ne-uX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://www.barbarianmeetscoding.com/images/il-pomodoro-svelte-select-task.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Kd5ne-uX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://www.barbarianmeetscoding.com/images/il-pomodoro-svelte-select-task.gif" title="We can select Tasks!" alt="A pomodoro app with a timer and a series of tasks. The user clicks on a button and selects a task." width="639" height="504"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Notifying The Outside World A Task Was Selected
&lt;/h3&gt;

&lt;p&gt;Excellent! The next step is to let the world outside of this component known that a task has been selected. Svelte lets us do that through event dispatching. Inside our component we can define our own domain specific events and dispatch them to our heart's content. &lt;/p&gt;

&lt;p&gt;A suitable event for our use case could be called &lt;code&gt;selectedTask&lt;/code&gt;:&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="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;createEventDispatcher&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;svelte&lt;/span&gt;&lt;span class="dl"&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;dispatch&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;createEventDispatcher&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;selectTask&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;task&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;activeTask&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;task&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="c1"&gt;// dispatch(eventName, eventData);&lt;/span&gt;
  &lt;span class="nx"&gt;dispatch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;taskSelected&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="na"&gt;task&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;activeTask&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 now, whenever the user selects a task, we'll call the &lt;code&gt;selectTask&lt;/code&gt; function that will:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Update the active task&lt;/li&gt;
&lt;li&gt;Notify the outside world that a task has been selected by dispatching a &lt;code&gt;taskSelected&lt;/code&gt; event with the currently active task&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In our app component we can subscribe to that new event just like we would subscribe to any other standard DOM event:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;main&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;h1&amp;gt;&lt;/span&gt;{title}&lt;span class="nt"&gt;&amp;lt;/h1&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;PomodoroTimer&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;TaskList&lt;/span&gt; &lt;span class="na"&gt;on:taskSelected=&lt;/span&gt;&lt;span class="s"&gt;{updateActiveTask}/&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/main&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;App.svelte&lt;/code&gt; component will now store its own version of the activeTask:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;script&amp;gt;&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;title&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;il Pomodoro&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;TaskList&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;./TaskList.svelte&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;PomodoroTimer&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;./PomodoroTimer.svelte&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;activeTask&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;updateActiveTask&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
    &lt;span class="nx"&gt;activeTask&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;detail&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;task&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That we can then send to our friend the Pomodoro Timer:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;main&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;h1&amp;gt;&lt;/span&gt;{title}&lt;span class="nt"&gt;&amp;lt;/h1&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;PomodoroTimer&lt;/span&gt; &lt;span class="err"&gt;{&lt;/span&gt;&lt;span class="na"&gt;activeTask&lt;/span&gt;&lt;span class="err"&gt;}&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;TaskList&lt;/span&gt; &lt;span class="na"&gt;on:taskSelected=&lt;/span&gt;&lt;span class="s"&gt;{updateActiveTask}/&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/main&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Pomodoro Timer Meets Active Task
&lt;/h3&gt;

&lt;p&gt;But in order to do so we to define a new prop inside our &lt;code&gt;PomodoroTimer&lt;/code&gt; component:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;script&amp;gt;&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;activeTask&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Since it doesn't make sense for a user to be able to interact with the pomodoro timer unless there's a task that is active, we can start by disabling the pomdoro timer in such a case:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;section&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;time&amp;gt;&lt;/span&gt;
    {formatTime(pomodoroTime)}
  &lt;span class="nt"&gt;&amp;lt;/time&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;footer&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; 
      &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"primary"&lt;/span&gt; &lt;span class="na"&gt;on:click=&lt;/span&gt;&lt;span class="s"&gt;{startPomodoro}&lt;/span&gt; 
      &lt;span class="na"&gt;disabled=&lt;/span&gt;&lt;span class="s"&gt;{currentState&lt;/span&gt; &lt;span class="err"&gt;!==&lt;/span&gt; &lt;span class="na"&gt;State.idle&lt;/span&gt; &lt;span class="err"&gt;||&lt;/span&gt; &lt;span class="err"&gt;!&lt;/span&gt;&lt;span class="na"&gt;activeTask&lt;/span&gt;&lt;span class="err"&gt;}&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;start&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;on:click=&lt;/span&gt;&lt;span class="s"&gt;{cancelPomodoro}&lt;/span&gt; 
      &lt;span class="na"&gt;disabled=&lt;/span&gt;&lt;span class="s"&gt;{currentState&lt;/span&gt; &lt;span class="err"&gt;!==&lt;/span&gt; &lt;span class="na"&gt;State.inProgress&lt;/span&gt; &lt;span class="err"&gt;||&lt;/span&gt; &lt;span class="err"&gt;!&lt;/span&gt;&lt;span class="na"&gt;activeTask&lt;/span&gt;&lt;span class="err"&gt;}&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;cancel&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/footer&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/section&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Cool!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--6LbuR5n5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://www.barbarianmeetscoding.com/images/il-pomodoro-svelte-disable-pomo.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--6LbuR5n5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://www.barbarianmeetscoding.com/images/il-pomodoro-svelte-disable-pomo.gif" title="Disabling the timer when no task is selected" alt="A pomodoro app with a timer and a series of tasks. The user clicks on a button and selects a task. When they select a task the pomodoro timer becomes active." width="639" height="504"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Finally, we can increment the pomodoros spent in a task when we complete a pomodoro. We update the &lt;code&gt;completePomodoro&lt;/code&gt; function in &lt;code&gt;PomodoroTimer.svelte&lt;/code&gt; to include that functionality:&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;function&lt;/span&gt; &lt;span class="nx"&gt;completePomodoro&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;
  &lt;span class="c1"&gt;// We add one more pomodoro to the active task&lt;/span&gt;
  &lt;span class="nx"&gt;activeTask&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;actualPomodoros&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; 
  &lt;span class="nx"&gt;completedPomodoros&lt;/span&gt;&lt;span class="o"&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;completedPomodoros&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;rest&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;LONG_BREAK_S&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nx"&gt;completedPomodoros&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="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;rest&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;SHORT_BREAK_S&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;But what happens if a user removes a task while the a pomodoro is running? A great user experience would prevent the user from being able to do that, either by disabling the remove button when a pomodoro is active or by showing a prompt to the user. For now however, we're just gonna leave that as a bonus exercise or future improvement.&lt;/p&gt;

&lt;p&gt;We're not displaying the pomodoros we've spent on a task quite yet, so let's not forget to do that. Back in the &lt;code&gt;TaskList.svelte&lt;/code&gt; component we update our component markup to show that information:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;  &lt;span class="nt"&gt;&amp;lt;ul&amp;gt;&lt;/span&gt;
    {#each tasks as task}
      &lt;span class="nt"&gt;&amp;lt;li&lt;/span&gt; &lt;span class="na"&gt;class:active=&lt;/span&gt;&lt;span class="s"&gt;{activeTask&lt;/span&gt; &lt;span class="err"&gt;===&lt;/span&gt; &lt;span class="na"&gt;task&lt;/span&gt;&lt;span class="err"&gt;}&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;on:click=&lt;/span&gt;&lt;span class="s"&gt;{()&lt;/span&gt; &lt;span class="err"&gt;=&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt; selectTask(task)}&amp;gt;&lt;span class="ni"&gt;&amp;amp;gt;&lt;/span&gt;&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"description"&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"text"&lt;/span&gt; &lt;span class="na"&gt;bind:value=&lt;/span&gt;&lt;span class="s"&gt;{task.description}&lt;/span&gt; &lt;span class="na"&gt;bind:this=&lt;/span&gt;&lt;span class="s"&gt;{lastInput}&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"pomodoros"&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"number"&lt;/span&gt; &lt;span class="na"&gt;bind:value=&lt;/span&gt;&lt;span class="s"&gt;{task.expectedPomodoros}&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="c"&gt;&amp;lt;!-- NEW input --&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"pomodoros small"&lt;/span&gt; &lt;span class="na"&gt;bind:value=&lt;/span&gt;&lt;span class="s"&gt;{task.actualPomodoros}&lt;/span&gt; &lt;span class="na"&gt;disabled&lt;/span&gt; &lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="c"&gt;&amp;lt;!-- END NEW --&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;on:click=&lt;/span&gt;&lt;span class="s"&gt;{()&lt;/span&gt; &lt;span class="err"&gt;=&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt; removeTask(task)}&amp;gt;X&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
    {/each}
  &lt;span class="nt"&gt;&amp;lt;/ul&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And our styles:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.pomodoros.small&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; 
  &lt;span class="nl"&gt;max-width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;40px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;text-align&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;center&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nc"&gt;.active&lt;/span&gt; &lt;span class="nt"&gt;input&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="nt"&gt;disabled&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;opacity&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0.6&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;And Tada! We finally have a working Pomodoro Technique app:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--biBmEYu_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://www.barbarianmeetscoding.com/images/il-pomodoro-svelte-finally-integrated.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--biBmEYu_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://www.barbarianmeetscoding.com/images/il-pomodoro-svelte-finally-integrated.gif" title="The pomodoro app finally integrated! Yiho!" alt="A pomodoro app with a timer and a series of tasks. The user clicks on a button and selects a task. When they select a task the pomodoro timer becomes active. The user clicks on start and the timer stars counting down." width="640" height="504"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  An Alternative Approach With Slightly Less Coupling
&lt;/h3&gt;

&lt;p&gt;While I was implementing the tasks and timer integration above I was somewhat unhappy with the idea that both the &lt;code&gt;TaskList&lt;/code&gt; component and &lt;code&gt;PomodoroTimer&lt;/code&gt; were modifying the same object &lt;code&gt;activeTask&lt;/code&gt;. The more places within an application that have access and can modify the same data, the harder it becomes to reason about the state of the application and how it changes over time. This, in turn, means that a bug related to that piece of data could be introduced in many different places within an application. And it also was somewhat boilerplatey to have to pull the &lt;code&gt;activeTask&lt;/code&gt; upwards to the parent &lt;code&gt;App&lt;/code&gt; component to them pipe it down again to &lt;code&gt;PomodoroTimer&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Here goes an alternative approach that sacrifies the independence of &lt;code&gt;PomodoroTimer&lt;/code&gt; from &lt;code&gt;TaskList&lt;/code&gt; but reduces the amount of code needed and reduces the coupling of data:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Include &lt;code&gt;PomodoroTimer&lt;/code&gt; component inside the &lt;code&gt;TaskList&lt;/code&gt; component&lt;/li&gt;
&lt;li&gt;We have all the data we need so we can enable/disable the &lt;code&gt;PomodoroTimer&lt;/code&gt; as needed&lt;/li&gt;
&lt;li&gt;Instead of passing the &lt;code&gt;activeTask&lt;/code&gt; into the &lt;code&gt;PomodoroTimer&lt;/code&gt;, the timer communicates when a task has been complete through an event and the &lt;code&gt;TaskList&lt;/code&gt; updates the &lt;code&gt;activeTask&lt;/code&gt;.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;PomodoroTimer&lt;/span&gt; &lt;span class="na"&gt;disable=&lt;/span&gt;&lt;span class="s"&gt;{activeTask}&lt;/span&gt; &lt;span class="na"&gt;on:completedPomodoro=&lt;/span&gt;&lt;span class="s"&gt;{()&lt;/span&gt; &lt;span class="err"&gt;=&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt; activeTask.actualPomodoros++}/&amp;gt;
&lt;span class="nt"&gt;&amp;lt;ul&amp;gt;&lt;/span&gt;
  &lt;span class="c"&gt;&amp;lt;!-- list of tasks remains unchanged --&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/ul&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Sharing State Using a Store
&lt;/h2&gt;

&lt;p&gt;Another way in which we can share state in Svelte are &lt;strong&gt;stores&lt;/strong&gt;. Where sharing state through props is extremely coupled to the DOM tree and the structure of your application, sharing state through stores is completely DOM independent. Using Svelte stores you can share data between any component of your application, no matter where they are, with just a single import (that of the store).&lt;/p&gt;

&lt;blockquote&gt;
&lt;h3&gt;
  
  
  What is a Store?
&lt;/h3&gt;

&lt;p&gt;A store is an object that helps you share data between the components of a Svelte application. Stores are independent from the DOM tree and the structure of your application, so they are really useful when you need to share state between components that are far away from each other, or that should be decoupled. Stores are also reactive: whenever their value changes they notify their consumers of this change so that they can react to it. A component becomes a consumer of a store by subscribing to it via the &lt;code&gt;subscribe&lt;/code&gt; method or &lt;code&gt;$&lt;/code&gt; (you'll see some examples below).&lt;/p&gt;

&lt;p&gt;For more information about stores &lt;a href="https://svelte.dev/docs#svelte_store"&gt;take a look at Svelte's Store documentation&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  The Active Task Store
&lt;/h3&gt;

&lt;p&gt;Let's create a new store that will allow us to share the active task between the &lt;code&gt;TaskList&lt;/code&gt; and the &lt;code&gt;PomodoroTimer&lt;/code&gt; components. The &lt;code&gt;TaskList&lt;/code&gt; component still has the complete list of tasks and will keep the responsibility of selecting the active task based on user input. This means that we can reuse much of the previous example. What's different? For one there won't be a &lt;code&gt;taskSelected&lt;/code&gt; event and even more interestingly the &lt;code&gt;activeTask&lt;/code&gt; will be a Svelte store.&lt;/p&gt;

&lt;p&gt;Let' start by creating the store in its own file &lt;code&gt;tasksStore.js&lt;/code&gt;:&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="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;writable&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;svelte/store&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;activeTask&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;writable&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="c1"&gt;// The initial value of this store is undefined.&lt;/span&gt;
&lt;span class="c1"&gt;// You can provide an initial value by passing it as an argument&lt;/span&gt;
&lt;span class="c1"&gt;// to the writable function. For example:&lt;/span&gt;
&lt;span class="c1"&gt;// &lt;/span&gt;
&lt;span class="c1"&gt;// const count = writable(0);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;activeTask&lt;/code&gt; is a &lt;strong&gt;writable store&lt;/strong&gt; which in layman terms means that it is a store that components can use to write information that can then be shared between components. Aside from being a way to share information, stores are also reactive which means that they notify components when data has changed. Let's see how we can take advantage of these capabilities to communicate the &lt;code&gt;TaskList&lt;/code&gt; and &lt;code&gt;PomodoroTimer&lt;/code&gt; components.&lt;/p&gt;

&lt;blockquote&gt;
&lt;h3&gt;
  
  
  Writable Stores
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://svelte.dev/docs#writable"&gt;Writable stores&lt;/a&gt; are stores that components can write to. In addition to &lt;code&gt;subscribe&lt;/code&gt; they have the &lt;code&gt;set&lt;/code&gt; and &lt;code&gt;update&lt;/code&gt; methods that allow components to set a value in the store, or update the current value by applying a function.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The next step is to have &lt;code&gt;TaskList&lt;/code&gt; import the &lt;code&gt;activeTask&lt;/code&gt; store replacing the former &lt;code&gt;let activeTask&lt;/code&gt; variable within the component.&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="c1"&gt;// import activeTask store&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;activeTask&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;./tasksStore.js&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// remove old variable&lt;/span&gt;
&lt;span class="c1"&gt;// let activeTask&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Since &lt;code&gt;activeTask&lt;/code&gt; is now a store we can't just set its value as we did before. So instead of:&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;function&lt;/span&gt; &lt;span class="nx"&gt;selectTask&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;task&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;activeTask&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;task&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;We need to use the &lt;code&gt;set&lt;/code&gt; method of the store:&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;function&lt;/span&gt; &lt;span class="nx"&gt;selectTask&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;task&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;activeTask&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kd"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;task&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;Likewise &lt;code&gt;activeTask&lt;/code&gt; no longer refers to the activeTask itself but to the store that stores its value. In order to retrieve the current value of a task you use the &lt;code&gt;get&lt;/code&gt; method. So intead of:&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;function&lt;/span&gt; &lt;span class="nx"&gt;removeTask&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;task&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;activeTask&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="nx"&gt;task&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
    &lt;span class="nx"&gt;selectTask&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;undefined&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="nx"&gt;tasks&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;tasks&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;remove&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;task&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;We write:&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="c1"&gt;// import get from svelte/store&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="kd"&gt;get&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;svelte/store&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// use it to retrieve the current value&lt;/span&gt;
&lt;span class="c1"&gt;// of the activeTask store and therefore&lt;/span&gt;
&lt;span class="c1"&gt;// the current task that is active&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;removeTask&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;task&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="kd"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;activeTask&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="nx"&gt;task&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
    &lt;span class="nx"&gt;selectTask&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;undefined&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="nx"&gt;tasks&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;tasks&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;remove&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;task&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;Using &lt;code&gt;set&lt;/code&gt; and &lt;code&gt;get&lt;/code&gt; can be quite wordy, so Svelte comes with an alternative syntax that lets you directly change and retrieve the value of a store by prepending it with a &lt;code&gt;$&lt;/code&gt; sign when you're inside a component. &lt;/p&gt;

&lt;p&gt;Using that convenient syntax we can update the previous example with this one:&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="c1"&gt;// use it to retrieve the current value&lt;/span&gt;
&lt;span class="c1"&gt;// of the activeTask store and therefore&lt;/span&gt;
&lt;span class="c1"&gt;// the current task that is active.&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;removeTask&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;task&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;$activeTask&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="nx"&gt;task&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
    &lt;span class="nx"&gt;selectTask&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;undefined&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="nx"&gt;tasks&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;tasks&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;remove&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;task&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// Use it to update the value of the activeTask.&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;selectTask&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;task&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;$activeTask&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;task&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;Which looks very similar to the original implementation. Isn't that cool? We're using as store to manage our state but it pretty much looks just like setting and reading a normal JavaScript variable.&lt;/p&gt;

&lt;blockquote&gt;
&lt;h3&gt;
  
  
  get and set or $store? Which one to use?
&lt;/h3&gt;

&lt;p&gt;If you're inside a component then there's no reason to use get and set. Prefer using the shorter and less boilerplatey $store syntax.&lt;/p&gt;

&lt;p&gt;Outside of a component, when retrieving or updating the value of a store you'll need to use the get and set methods. Why? Because the $store syntax automatically subscribes and unsubscribes from a store by taking advantage of a component lifecycle events. You mount a component, you subscribe, you destroy a component, you unsubscribe. In the context of a vanilla JavaScript module however there's no concept of a lifecycle. Therefore the compiler wouldn't be able to know when it'd be a suitable time to unsubscribe from a store leading to memory leaks.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Whe can also use &lt;code&gt;$activeTask&lt;/code&gt; within our component's template to check whether a given &lt;code&gt;li&lt;/code&gt; belongs to the active task and highlight it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;ul&amp;gt;&lt;/span&gt;
  {#each tasks as task}
    &lt;span class="c"&gt;&amp;lt;!-- update $activeTask here --&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;li&lt;/span&gt; &lt;span class="na"&gt;class:active=&lt;/span&gt;&lt;span class="s"&gt;{$activeTask&lt;/span&gt; &lt;span class="err"&gt;===&lt;/span&gt; &lt;span class="na"&gt;task&lt;/span&gt;&lt;span class="err"&gt;}&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="c"&gt;&amp;lt;!-- END update --&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;on:click=&lt;/span&gt;&lt;span class="s"&gt;{()&lt;/span&gt; &lt;span class="err"&gt;=&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt; selectTask(task)}&amp;gt;&lt;span class="ni"&gt;&amp;amp;gt;&lt;/span&gt;&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"description"&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"text"&lt;/span&gt; &lt;span class="na"&gt;bind:value=&lt;/span&gt;&lt;span class="s"&gt;{task.description}&lt;/span&gt; &lt;span class="na"&gt;bind:this=&lt;/span&gt;&lt;span class="s"&gt;{lastInput}&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"pomodoros"&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"number"&lt;/span&gt; &lt;span class="na"&gt;bind:value=&lt;/span&gt;&lt;span class="s"&gt;{task.expectedPomodoros}&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"pomodoros small"&lt;/span&gt; &lt;span class="na"&gt;bind:value=&lt;/span&gt;&lt;span class="s"&gt;{task.actualPomodoros}&lt;/span&gt; &lt;span class="na"&gt;disabled&lt;/span&gt; &lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;on:click=&lt;/span&gt;&lt;span class="s"&gt;{()&lt;/span&gt; &lt;span class="err"&gt;=&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt; removeTask(task)}&amp;gt;X&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
  {/each}
&lt;span class="nt"&gt;&amp;lt;/ul&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So now we can set the value of the &lt;code&gt;activeTask&lt;/code&gt; whenever a user selects it within the &lt;code&gt;TaskList&lt;/code&gt; component. The next step is to remove all references of &lt;code&gt;activeTask&lt;/code&gt; from &lt;code&gt;App.svelte&lt;/code&gt; and update our &lt;code&gt;PomodoroTimer&lt;/code&gt; component to make use of the new store. &lt;/p&gt;

&lt;p&gt;We update the &lt;code&gt;completePomodoro&lt;/code&gt; method using the same &lt;code&gt;$activeTask&lt;/code&gt; syntax we learned earlier:&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="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;activeTask&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;./tasksStore.js&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;completePomodoro&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;
  &lt;span class="c1"&gt;// Get the current active task and add a pomodoro&lt;/span&gt;
  &lt;span class="nx"&gt;$activeTask&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;actualPomodoros&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; 
  &lt;span class="nx"&gt;completedPomodoros&lt;/span&gt;&lt;span class="o"&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;completedPomodoros&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;rest&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;LONG_BREAK_S&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nx"&gt;completedPomodoros&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="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;rest&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;SHORT_BREAK_S&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;And the template to enable and disable the timer whenever a task is active or not:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;section&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;time&amp;gt;&lt;/span&gt;
    {formatTime(pomodoroTime)}
  &lt;span class="nt"&gt;&amp;lt;/time&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;footer&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"primary"&lt;/span&gt; 
      &lt;span class="na"&gt;on:click=&lt;/span&gt;&lt;span class="s"&gt;{startPomodoro}&lt;/span&gt; 
      &lt;span class="na"&gt;disabled=&lt;/span&gt;&lt;span class="s"&gt;{currentState&lt;/span&gt; &lt;span class="err"&gt;!==&lt;/span&gt; &lt;span class="na"&gt;State.idle&lt;/span&gt; &lt;span class="err"&gt;||&lt;/span&gt; &lt;span class="err"&gt;!$&lt;/span&gt;&lt;span class="na"&gt;activeTask&lt;/span&gt;&lt;span class="err"&gt;}&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;start&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; 
      &lt;span class="na"&gt;on:click=&lt;/span&gt;&lt;span class="s"&gt;{cancelPomodoro}&lt;/span&gt; 
      &lt;span class="na"&gt;disabled=&lt;/span&gt;&lt;span class="s"&gt;{currentState&lt;/span&gt; &lt;span class="err"&gt;!==&lt;/span&gt; &lt;span class="na"&gt;State.inProgress&lt;/span&gt; &lt;span class="err"&gt;||&lt;/span&gt; &lt;span class="err"&gt;!$&lt;/span&gt;&lt;span class="na"&gt;activeTask&lt;/span&gt;&lt;span class="err"&gt;}&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;cancel&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/footer&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/section&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you take a look at the page right now (remember you can run the local dev environment with &lt;code&gt;npm run dev&lt;/code&gt;) you'll be happy to see that everything is still working. Wihoo!&lt;/p&gt;

&lt;blockquote&gt;
&lt;h3&gt;
  
  
  What Type Of Stores Are Available in Svelte?
&lt;/h3&gt;

&lt;p&gt;In addition to &lt;a href="https://svelte.dev/docs#writable"&gt;writable stores&lt;/a&gt; Svelte has &lt;a href="https://svelte.dev/docs#readable"&gt;readable&lt;/a&gt; and &lt;a href="https://svelte.dev/docs#derived"&gt;derived&lt;/a&gt; stores. Readable stores are stores whose value can't be updated by a component. Derived stores are stores whose value is derived from other stores. Whenever these stores change, the value in the derived store is updated.&lt;/p&gt;

&lt;p&gt;If you want to &lt;a href="https://svelte.dev/docs#svelte_store"&gt;learn more about Svelte stores take a look at the Svelte documentation&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Props vs Stores
&lt;/h2&gt;

&lt;p&gt;Now that we've completed two different versions of our Pomodoro Technique app using both props and stores let's take a moment to reflect and compare both approaches:&lt;/p&gt;

&lt;h3&gt;
  
  
  Props
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Svelte components define their interface with the outside world using props&lt;/strong&gt;. Using props allows parent components to communicate with children and &lt;em&gt;vice versa&lt;/em&gt;. You can send data downwards from parent to child using props and upwards from children to parents using events.&lt;/p&gt;

&lt;h4&gt;
  
  
  Props Pros
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Sending data back and forth props is quite simple.&lt;/li&gt;
&lt;li&gt;Understanding the contract used to interact with a component is quite straightforward as it is defined by its props.&lt;/li&gt;
&lt;li&gt;Following the flow of data using props is as easy as seeing how data flows inside the component via props and comes out of the component via events.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Props Cons
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;This type of state management creates a coupling between components and makes your application a little bit rigid: If a new requirement forces you to move a component to a different location in the page you may need to update the way you provide information to that component. &lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  When to Use Props
&lt;/h4&gt;

&lt;p&gt;Because of all of the above it seems like props are a good solution for low level components that are completely isolated (a date picker, a type ahead, etc), or components that are near each other (in the DOM) and part of a closely related unit.&lt;/p&gt;

&lt;h3&gt;
  
  
  Stores
&lt;/h3&gt;

&lt;p&gt;Svelte stores are an extremely convenient way to share data between components in a loosely coupled way. Since you only need to import them to start accessing and changing data, they can be used to communicate any component anywhere within your application DOM tree.&lt;/p&gt;

&lt;h4&gt;
  
  
  Store Pros
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;They are more flexible than props and allow you to communicate components that are far away in your application DOM tree&lt;/strong&gt;. They don't force you to pass the information one step at a time through the DOM tree, one import and you can access and change your data.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;They establish a loose coupling between components&lt;/strong&gt;. Using a store to communicate between components leads to flexible web applications where a requirement to change the layout of your application requires no changes in your data handling logic. That is, if you have two components that communicate using a store and all of the sudden you get the requirement to move one of them far across the page, there's no problem, you can just move it away and there's no additional code changes required. Compare that to a solution where both components communicate through props and you would be forced to change your state management strategy.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Store Cons
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;The data interactions between components aren't as straightforward as when using props. Since the interactions no longer happen between components, but between a component and a store, it may be harder to reason about how actions on a component affect other components.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  When to Use Stores
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Use stores when you need to communicate between components that are far away in your application DOM tree&lt;/li&gt;
&lt;li&gt;Use stores when you want to keep your options open and your components loosely coupled (e.g. if you expect that you may need to)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Are There Any Other Way to Share State in Svelte?
&lt;/h2&gt;

&lt;p&gt;In addition to props and stores, Svelte offers a middle ground solution: &lt;strong&gt;&lt;a href="https://svelte.dev/docs#setContext"&gt;The Context API&lt;/a&gt;&lt;/strong&gt;. The Context API allows you to communicate between components without passing lots of props or events deep inside the DOM tree. It consists on just two methods &lt;code&gt;setContext(key, value)&lt;/code&gt; and &lt;code&gt;getContext(key)&lt;/code&gt;. A parent component can use the &lt;code&gt;setContext(key, value)&lt;/code&gt; method to save some data, that can then be retrieved by any child of that component using &lt;code&gt;getContext(key)&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;You can find an example of &lt;a href="https://svelte.dev/tutorial/context-api"&gt;how to use The Context API within Svelte Tutorials&lt;/a&gt;.&lt;/p&gt;

&lt;blockquote&gt;
&lt;h3&gt;
  
  
  Looking for the source code for the pomodoro app?
&lt;/h3&gt;

&lt;p&gt;Look no more! You can find it on &lt;a href="https://github.com/Vintharas/il-pomodoro-in-svelte"&gt;GitHub&lt;/a&gt; ready to be cloned and enjoyed, or on &lt;a href="https://svelte.dev/repl/80e4829f3f0e42a7958c32f67a422d0a?version=3.18.1"&gt;the Svelte REPL&lt;/a&gt; where you can tinker with it right away.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  More Reflections About Svelte
&lt;/h2&gt;

&lt;p&gt;Working with Svelte continues to be very pleasant. In addition to my previous reflections (&lt;a href="https://www.barbarianmeetscoding.com/blog/2019/12/27/discovering-svelte-getting-started#some-reflections-so-far"&gt;1&lt;/a&gt;, &lt;a href="https://www.barbarianmeetscoding.com/blog/2019/12/29/discovering-svelte-adding-some-tasks-and-pomodoros#some-more-reflections-so-far"&gt;2&lt;/a&gt;, &lt;a href="https://www.barbarianmeetscoding.com/blog/2020/01/04/discovering-svelte-creating-a-pomodoro-timer#more-reflections"&gt;3&lt;/a&gt;) I've found that:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It is very easy to communicate components using props and events. The syntax is very straightfoward, lightweight and easy to remember.&lt;/li&gt;
&lt;li&gt;I really like that Svelte comes with a state management solution built-in and how easy it is to use stores change data or read it in a reactive fashion.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Concluding
&lt;/h2&gt;

&lt;p&gt;In this article we finally connected everything together and have a working pomodoro timer. Yihoo! We learned how you can use props and events to communicate between components that are near each other in the DOM tree, and how you can use stores to share data between components in a more loosely coupled fashion.&lt;/p&gt;

&lt;p&gt;In upcoming parts of the series will dive into testing, async, animations and more. See you! Have a wonderful day!&lt;/p&gt;




&lt;ol&gt;

&lt;li id="fn1"&gt;
&lt;p&gt;Check &lt;a href="https://www.barbarianmeetscoding.com/projects/ilpomodoro/"&gt;this super old pomodoro technique app&lt;/a&gt; I wrote using Knockout.js back in the day I started doing web development. ↩&lt;/p&gt;
&lt;/li&gt;

&lt;/ol&gt;

</description>
      <category>svelte</category>
      <category>javascript</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Peak: Secrets From the New Science Of Expertise Or How To Get Better At Anything</title>
      <dc:creator>Jaime González García</dc:creator>
      <pubDate>Thu, 16 Jan 2020 22:09:44 +0000</pubDate>
      <link>https://dev.to/vintharas/peak-secrets-from-the-new-science-of-expertise-26f6</link>
      <guid>https://dev.to/vintharas/peak-secrets-from-the-new-science-of-expertise-26f6</guid>
      <description>&lt;p&gt;This is an adapted twitter thread that I thought useful enough to improve slightly and crosspost to Dev.to. Hope you find it helpful! 😁👍&lt;/p&gt;

&lt;p&gt;&lt;iframe class="tweet-embed" id="tweet-1217720266157121536-310" src="https://platform.twitter.com/embed/Tweet.html?id=1217720266157121536"&gt;
&lt;/iframe&gt;

  // Detect dark theme
  var iframe = document.getElementById('tweet-1217720266157121536-310');
  if (document.body.className.includes('dark-theme')) {
    iframe.src = "https://platform.twitter.com/embed/Tweet.html?id=1217720266157121536&amp;amp;theme=dark"
  }



&lt;/p&gt;

&lt;p&gt;We recently started a book club at our office centered around two pillars: Diversity, Equity and Inclusion, and Personal Development and Wellness. We pick a book on each topic every quarter, read it and then discuss it. The books for this quarter are:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href="https://amzn.to/2TuCzSN" rel="noopener noreferrer"&gt;The Gendered Brain&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://t.co/ssBmn45Qbm?amp=1" rel="noopener noreferrer"&gt;Peak: Secrets From the New Science Of Expertise&lt;/a&gt;&lt;/li&gt;
&lt;/ol&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%2Fimages-na.ssl-images-amazon.com%2Fimages%2FI%2F618%252BENSR3ML._SX324_BO1%2C204%2C203%2C200_.jpg" 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%2Fimages-na.ssl-images-amazon.com%2Fimages%2FI%2F618%252BENSR3ML._SX324_BO1%2C204%2C203%2C200_.jpg"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimages-na.ssl-images-amazon.com%2Fimages%2FI%2F41gsOAxpJgL._SX326_BO1%2C204%2C203%2C200_.jpg" 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%2Fimages-na.ssl-images-amazon.com%2Fimages%2FI%2F41gsOAxpJgL._SX326_BO1%2C204%2C203%2C200_.jpg"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Of the two, I started reading &lt;a href="https://t.co/ssBmn45Qbm?amp=1" rel="noopener noreferrer"&gt;Peak&lt;/a&gt; because they have it only for a limited amount of time in &lt;a href="https://www.storytel.com/se/sv/?gclid=CjwKCAiAsIDxBRAsEiwAV76N869dPau7zkDsjezi5eFjHmLDivYbNTb76UStt3nsG5UG39Y1baef3BoC9zgQAvD_BwE" rel="noopener noreferrer"&gt;Storytel&lt;/a&gt; my audiobook service of choice. 🇸🇪&lt;/p&gt;

&lt;p&gt;The book is extremely interesting and has filled me with optimism and motivation to put in more work and effort to kick ass at the different endeavors that matter to me: coding, parenting, being a great husband, a good person, exercising... 😁&lt;/p&gt;

&lt;p&gt;Here are some notes on &lt;strong&gt;how you can be more awesome at doing the stuff you care about&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Consistent Practice Beats Natural Talent
&lt;/h2&gt;

&lt;p&gt;You can improve at something through &lt;strong&gt;consistent&lt;/strong&gt; practice. The brain is very malleable and will adapt to the activities you spend your time doing. So as you practice something, you'll start becoming more proficient at it. &lt;strong&gt;Consistent practice and effort beat natural talent&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;But not all kinds of practices are equally effective.&lt;/p&gt;

&lt;p&gt;Just spending hours practicing by doing something will only get you so far. To become a true master of a skill you need &lt;strong&gt;purposeful or even better deliberate practice&lt;/strong&gt;. &lt;/p&gt;

&lt;h2&gt;
  
  
  Purposeful Practice: How to get Super Good at Something on Your Own
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;“So here we have &lt;strong&gt;purposeful practice&lt;/strong&gt; in a nutshell: Get outside your comfort zone but do it in a focused way, with clear goals, a plan for reaching those goals, and a way to monitor your progress. Oh, and figure out a way to maintain your motivation.”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Getting outside of your comfort zone is a key ingredient if you want to get really good at something&lt;/strong&gt;. So push yourself a little bit harder every time.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The reason that most people don’t possess these extraordinary physical capabilities isn’t because they don’t have the capacity for them, but rather because they’re satisfied to live in the comfortable rut of homeostasis and never do the work that is required to get out of it. They live in the world of “good enough.” The same thing is true for all the mental activities we engage in&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The other key ingredient to mastery is &lt;strong&gt;feedback&lt;/strong&gt;: having a way to asses whether you're getting better or not. This helps you validate your learning and keeps you motivated.&lt;/p&gt;

&lt;h2&gt;
  
  
  Deliberate Practice: Achieving True Mastery Guided By Experts
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Deliberate practice&lt;/strong&gt; is a step over purposeful practice and requires:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;A well developed and rigorous field (like music, chess, ballet, etc...)&lt;/li&gt;
&lt;li&gt;A teacher that can guide and tailor your practice.&lt;/li&gt;
&lt;/ol&gt;

&lt;blockquote&gt;
&lt;p&gt;“… we are drawing a clear distinction between purposeful practice— in which a person tries very hard to push himself or herself to improve— and practice that is both purposeful and informed. In particular, deliberate practice is informed and guided by the best performers’ accomplishments and by an understanding of what these expert performers do to excel. Deliberate practice is purposeful practice that knows where it is going and how to get there.” (emphasis mine)&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The main purpose of deliberate practice is to develop effective &lt;strong&gt;mental representations&lt;/strong&gt; that make you more effective at learning and performing a skill. A person that can memorize 300 digits doesn't use raw memorization to do it, instead she builds mental representations to encode those digits in a way that bypasses the limitations of short-term memory. Expert teachers can really aid you in your practice because they already know the most useful mental representations in their field.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Knowing is never as good as doing&lt;/strong&gt;. Most traditional education and learning systems focus a lot on learning knowledge and very little on putting it to practice. Deliberate practice focuses on doing. That's the most effective way to master a skill. The next time you find yourself learning something by reading a book, or watching videos consider investing your time in doing instead (e.g. building an app instead of watching someone else build an app).&lt;/p&gt;

&lt;p&gt;An interesting fact is that &lt;strong&gt;deliberate practice isn't fun&lt;/strong&gt;. Surveyed master violinists all agreed that practicing scales and other exercises that really contributed to the improvement of their skills weren't fun at all. But they practiced on because it was what was needed to become a truly awesome violinist.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where Can I Find More?
&lt;/h2&gt;

&lt;p&gt;If you find this topic interesting, here are a couple of articles that will help you get started with deliberate practice:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://jamesclear.com/beginners-guide-deliberate-practice" rel="noopener noreferrer"&gt;A Beginner's Guide to Deliberate Practice&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.nateliason.com/blog/deliberate-practice" rel="noopener noreferrer"&gt;How to Use Deliberate Practice to Reach the Top 1% of Your Field&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Or you &lt;a href="https://t.co/ssBmn45Qbm?amp=1" rel="noopener noreferrer"&gt;can read the book&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Now go become a master! 💪😀💪&lt;/p&gt;

&lt;p&gt;🔥🧙‍♂️🔥&lt;/p&gt;

&lt;p&gt;P.S. &lt;strong&gt;Fun fact&lt;/strong&gt;: You may have heard that you need to put in 10000 hours to truly master a skill. This statement is popularly known as the 10000 rule and it was popularized by Malcom Gladwell in his book &lt;a href="https://amzn.to/38oFocz" rel="noopener noreferrer"&gt;Outliers&lt;/a&gt;. Well Malcolm took that tidbit from the same research done in this book and the authors make an attempt to correct him in this essay: &lt;a href="https://www.salon.com/2016/04/10/malcolm_gladwell_got_us_wrong_our_research_was_key_to_the_10000_hour_rule_but_heres_what_got_oversimplified/" rel="noopener noreferrer"&gt;Malcolm Gladwell got us wrong: Our research was key to the 10,000-hour rule, but here's what got oversimplified&lt;/a&gt;&lt;/p&gt;

</description>
      <category>productivity</category>
      <category>books</category>
      <category>career</category>
    </item>
    <item>
      <title>Learn Svelte: Creating a Pomodoro Timer</title>
      <dc:creator>Jaime González García</dc:creator>
      <pubDate>Mon, 13 Jan 2020 23:33:49 +0000</pubDate>
      <link>https://dev.to/vintharas/learn-svelte-creating-a-pomodoro-timer-1fcn</link>
      <guid>https://dev.to/vintharas/learn-svelte-creating-a-pomodoro-timer-1fcn</guid>
      <description>&lt;p&gt;&lt;em&gt;This article was originally published on &lt;a href="https://www.barbarianmeetscoding.com/blog/2020/01/04/discovering-svelte-creating-a-pomodoro-timer"&gt;Barbarian Meets Coding&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://svelte.dev/"&gt;Svelte&lt;/a&gt; is a modern web framework that takes a novel approach to building web applications by moving the bulk of its work from runtime to compile-time. Being a compiler-first framework allows Svelte to do some very interesting stuff that is unavailable to other frameworks like disappearing from your application at runtime, or allowing for a component centered development with HTML, JavaScript and CSS coexisting within the same Svelte file in a very web standards friendly fashion.&lt;/p&gt;

&lt;p&gt;In this series we'll follow along as I use Svelte for the first time to build an app. I'll use my go-to project[^1] to learn new frameworks: A &lt;a href="https://francescocirillo.com/pages/pomodoro-technique"&gt;Pomodoro Technique&lt;/a&gt; app, which is a little bit more involved than a TODO list in that it has at least a couple of components (a timer and a list of tasks) that need to interact with each other.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;In this part four of the series we continue coding along as we create a pomodoro timer that will allow us to work on a given task with our complete focus and full attention. Let's get started!&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Haven't read the other articles in this series? Then you may want to take a look at this &lt;a href="https://www.barbarianmeetscoding.com/blog/2019/12/23/discovering-svelte"&gt;list of resources for getting started with Svelte&lt;/a&gt;, and the &lt;a href="https://www.barbarianmeetscoding.com/blog/2019/12/27/discovering-svelte-getting-started"&gt;first&lt;/a&gt; and &lt;a href="https://www.barbarianmeetscoding.com/blog/2019/12/29/discovering-svelte-adding-some-tasks-and-pomodoros"&gt;second&lt;/a&gt; parts of building the Pomodoro Technique app.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Working on a Task with Your Full Attention
&lt;/h2&gt;

&lt;p&gt;In the last part of this series we learned how when using the Pomodoro Technique you'll typically start your day sitting down, deciding what you'll achieve during the day and breaking it in as many pomodoros as you think it'll take. &lt;strong&gt;A pomodoro is a special unit of time used in &lt;a href="https://francescocirillo.com/pages/pomodoro-technique"&gt;The Pomodoro Technique&lt;/a&gt; which represents 25 minutes of uninterrupted work focusing on a single task&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The next step in The Pomodoro Technique consists in:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Picking the most important task, &lt;/li&gt;
&lt;li&gt;Starting the pomodoro timer, and...&lt;/li&gt;
&lt;li&gt;Start kicking ass by focusing single-mindedly on that task for the next 25 minutes. &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;After the 25 minutes have passed, you'll rest for 5 minutes, and then start a new pomodoro. After 4 pomodoros have been completed you'll rest for 20 minutes. It is important that both when the pomodoro starts and when it finishes, we get a auditory cue which will act as trigger to first get us into focus, and then to get us into a resting mindset.&lt;/p&gt;

&lt;p&gt;So if we were to attemp to build a pomodoro timer to support this workflow, it would need to fullfill the following set of requirements:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It should have three states: An &lt;em&gt;active state&lt;/em&gt; where we are working on a task and a state where we're &lt;em&gt;resting&lt;/em&gt; and an &lt;em&gt;idle state&lt;/em&gt; where we're not doing anything at all.&lt;/li&gt;
&lt;li&gt;In the &lt;strong&gt;active state&lt;/strong&gt; it should count from 25 minutes downwards

&lt;ul&gt;
&lt;li&gt;When a pomodoro starts we should hear a cue&lt;/li&gt;
&lt;li&gt;When a pomodoro ends we should hear another cue&lt;/li&gt;
&lt;li&gt;We should be able to cancel or stop a pomodoro any time&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;In the &lt;strong&gt;resting state&lt;/strong&gt; the timer should count from 5 or 20 minutes downwards

&lt;ul&gt;
&lt;li&gt;It should count from 20 minutes downwards when 4 pomodoros have been completed&lt;/li&gt;
&lt;li&gt;It should count from 5 minutes downwards any other time&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;In the &lt;strong&gt;idle state&lt;/strong&gt; nothing happens&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Once a pomodoro has been completed whe should increase the number of pomodoros invested in the task in progress, and whenever a pomodoro is cancelled we need to type down the reason why (how were we interrupted? Why couldn't we keep our focus?). In this part of the series we'll just focus on building the timer itself, and in future articles we'll continue improving the timer and finally putting everything together. &lt;strong&gt;Let's get to it!&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The Pomodoro Timer
&lt;/h2&gt;

&lt;p&gt;Since a pomodoro timer seems like a completely separate responsibility from anything else in our app up to this point it deserves its own component. So I'll start by creating a new component called &lt;code&gt;PomodoroTimer.svelte&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;
  Hi, I'm a pomodoro timer. Yo!
&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And adding it to our &lt;code&gt;App.svelte&lt;/code&gt; component:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;script&amp;gt;&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;title&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;il Pomodoro&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;TaskList&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;./TaskList.svelte&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;PomodoroTimer&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;./PomodoroTimer.svelte&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;main&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;h1&amp;gt;&lt;/span&gt;{title}&lt;span class="nt"&gt;&amp;lt;/h1&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;PomodoroTimer&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;TaskList&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/main&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I remember the rookie mistake I made in earlier parts of the series and I import the component before I use it in my template. Now my dev environment should display the new component... &lt;/p&gt;

&lt;p&gt;Although it doesn't... &lt;/p&gt;

&lt;p&gt;Weird... &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Recheck, look at typos, refresh, rerun dev server&lt;/strong&gt;. After some troubleshooting I realize that I need to do a hard refresh in my browser, it seems like it is caching &lt;code&gt;localhost:5000&lt;/code&gt;. So hard refresh it is and now I see the new component. &lt;strong&gt;Sweet!&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Starting a Pomodoro
&lt;/h2&gt;

&lt;p&gt;Let's begin by implementing a way to start working on our first pomodoro. We're going to need:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;A button to kick off the pomodoro&lt;/li&gt;
&lt;li&gt;A way to represent the time left in a pomodoro&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The button is quite simple. We update our svelte component template to include a new button that when clicked will start a new pomodoro:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;section&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;
    Hi, I'm a pomodoro timer. Yo!
  &lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;on:click=&lt;/span&gt;&lt;span class="s"&gt;{startPomodoro}&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;start&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/section&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Since we don't have a pomodoro timer just yet, we'll start by creating an empty &lt;code&gt;startPomodoro&lt;/code&gt; function for the time being:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;script&amp;gt;&lt;/span&gt;
  &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;startPomodoro&lt;/span&gt;&lt;span class="p"&gt;(){}&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we need a way to represent the pomodoro timer. The initial state of the timer will be the length of a pomodoro (25 minutes). And since we'll often interact with the timer by decreasing a second at a time, we'll represent the length of a pomodoro in seconds (instead of minutes):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;script&amp;gt;&lt;/span&gt;
  &lt;span class="c1"&gt;// length of a pomodoro in seconds&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;POMODORO_S&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;25&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;60&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="c1"&gt;// time left in the current pomodoro&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;pomodoroTime&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;POMODORO_S&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;startPomodoro&lt;/span&gt;&lt;span class="p"&gt;(){}&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Since I don't like having magic numbers in my code I'll extract the time conversion between minutes and seconds inside a function:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;script&amp;gt;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;minutesToSeconds&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;minutes&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;minutes&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;60&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="c1"&gt;// length of a pomodoro in seconds&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;POMODORO_S&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;minutesToSeconds&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;25&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="c1"&gt;// time left in the current pomodoro&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;pomodoroTime&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;POMODORO_S&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;startPomodoro&lt;/span&gt;&lt;span class="p"&gt;(){}&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we need to represent that time in the template in the format &lt;code&gt;MM:SS&lt;/code&gt;. We can use a function to transform the &lt;code&gt;pomodoroTime&lt;/code&gt; into the desired format:&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;function&lt;/span&gt; &lt;span class="nx"&gt;formatTime&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;timeInSeconds&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;minutes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;secondsToMinutes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;timeInSeconds&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;remainingSeconds&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;timeInSeconds&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="mi"&gt;60&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;padWithZeroes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;minutes&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="nx"&gt;padWithZeroes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;remainingSeconds&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="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Which uses a couple of helpers:&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;secondsToMinutes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;seconds&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;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;floor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;seconds&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;60&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;padWithZeroes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&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="nx"&gt;number&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;toString&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nx"&gt;padStart&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="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;0&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;Having defined &lt;code&gt;formatTime&lt;/code&gt; we can use it in our template to transform the value of &lt;code&gt;pomodoroTime&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;section&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;
    {formatTime(pomodoroTime)}
  &lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;footer&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;on:click=&lt;/span&gt;&lt;span class="s"&gt;{startPomodoro}&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;start&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/footer&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/section&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The complete component now looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;script&amp;gt;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;minutesToSeconds&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;minutes&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;minutes&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;60&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;secondsToMinutes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;seconds&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;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;floor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;seconds&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;60&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;padWithZeroes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&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="nx"&gt;number&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;toString&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nx"&gt;padStart&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="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;0&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="c1"&gt;// length of a pomodoro in seconds&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;POMODORO_S&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;minutesToSeconds&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;25&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="c1"&gt;// time left in the current pomodoro&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;pomodoroTime&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;POMODORO_S&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;formatTime&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;timeInSeconds&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;minutes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;secondsToMinutes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;timeInSeconds&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;remainingSeconds&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;timeInSeconds&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="mi"&gt;60&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;padWithZeroes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;minutes&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="nx"&gt;padWithZeroes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;remainingSeconds&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="p"&gt;}&lt;/span&gt;

  &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;startPomodoro&lt;/span&gt;&lt;span class="p"&gt;(){}&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;section&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;
    {formatTime(pomodoroTime)}
  &lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;footer&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;on:click=&lt;/span&gt;&lt;span class="s"&gt;{startPomodoro}&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;start&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/footer&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/section&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And looks like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--zJXr1nUG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://www.barbarianmeetscoding.com/images/svelte-pomodoro-timer.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--zJXr1nUG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://www.barbarianmeetscoding.com/images/svelte-pomodoro-timer.jpg" title="A pomodoro timer!" alt="A pomodoro app with a timer and a series of tasks" width="800" height="547"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;But if we click on the button &lt;code&gt;start&lt;/code&gt; nothing happens. We still need to implement the &lt;code&gt;startPomodro&lt;/code&gt; function. Now that we have an initial implementation for the timer we can fill in its implementation:&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;function&lt;/span&gt; &lt;span class="nx"&gt;startPomodoro&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="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;pomodoroTime&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="p"&gt;},&lt;/span&gt;&lt;span class="mi"&gt;1000&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;And &lt;strong&gt;TaDa!&lt;/strong&gt; we have a working timer:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--O8hxJa4l--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://www.barbarianmeetscoding.com/images/svelte-pomodoro-timer-starts.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--O8hxJa4l--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://www.barbarianmeetscoding.com/images/svelte-pomodoro-timer-starts.gif" title="A pomodoro timer starts its countdown" alt="A pomodoro app with a timer and a series of tasks. The user clicks on start and the pomodoro timer starts its countdown." width="800" height="487"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Completing a Pomodoro and Taking a Break
&lt;/h2&gt;

&lt;p&gt;Now there's two options, we can either focus on working on the task at hand and complete a pomodoro (Yihoo! Great job!) or we can cancel the pomodoro because we've been interrupted by something or someone.&lt;/p&gt;

&lt;p&gt;When we complete a pomodoro, two things should happen:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The pomodoro count of the current task should increase by one&lt;/li&gt;
&lt;li&gt;The timer goes into a resting state and starts counting down&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Since we aren't going to integrate the timer with the rest of the app yet, let's focus on item number #2 by creating a new function &lt;code&gt;completePomodoro&lt;/code&gt;. Whenever the &lt;code&gt;pomodoroTime&lt;/code&gt; count down arrives to &lt;code&gt;0&lt;/code&gt; we complete the pomodoro calling this new function:&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;function&lt;/span&gt; &lt;span class="nx"&gt;startPomodoro&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="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;pomodoroTime&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;completePomodoro&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="nx"&gt;pomodoroTime&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="p"&gt;},&lt;/span&gt;&lt;span class="mi"&gt;1000&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;Whenever we complete a pomodoro we're going to slide into a resting state counting down from &lt;code&gt;20&lt;/code&gt; minutes or &lt;code&gt;5&lt;/code&gt; minutes depending on whether we have completed 4 pomodoros up to this point. So:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;We define a couple of constants to store the lenghts of the breaks &lt;code&gt;LONG_BREAK_S&lt;/code&gt; and &lt;code&gt;SHORT_BREAK_S&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;We define a &lt;code&gt;completedPomodoros&lt;/code&gt; variable we'll use to keep track of how many pomodoros we have completed up to this point. This variable will determine whether we take the short or long break.&lt;/li&gt;
&lt;li&gt;We implement the &lt;code&gt;completePomodoro&lt;/code&gt; to complete a pomodoro and jump into the resting state:
&lt;/li&gt;
&lt;/ul&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;LONG_BREAK_S&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;minutesToSeconds&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;20&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;SHORT_BREAK_S&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;minutesToSeconds&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="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;completedPomodoros&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="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;completePomodoro&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;
    &lt;span class="nx"&gt;completedPomodoros&lt;/span&gt;&lt;span class="o"&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;completedPomodoros&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;rest&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;LONG_BREAK_S&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="nx"&gt;completedPomodoros&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="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;rest&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;SHORT_BREAK_S&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;We still have an interval running our counting down function so we need to make sure to stop that interval before we proceed. We update the &lt;code&gt;startPomodoro&lt;/code&gt; function to store a reference to the interval:&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;interval&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;startPomodoro&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; 
  &lt;span class="nx"&gt;interval&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;setInterval&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;pomodoroTime&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;completePomodoro&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="nx"&gt;pomodoroTime&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="p"&gt;},&lt;/span&gt;&lt;span class="mi"&gt;1000&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;And clear it whenever we complete a pomodoro:&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;function&lt;/span&gt; &lt;span class="nx"&gt;completePomodoro&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;
  &lt;span class="nx"&gt;clearInterval&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;interval&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
  &lt;span class="nx"&gt;completedPomodoros&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="c1"&gt;// TODO: update the current task with a completed pomodoro&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;completedPomodoros&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;rest&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;LONG_BREAK_S&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nx"&gt;completedPomodoros&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="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;rest&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;SHORT_BREAK_S&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;The &lt;code&gt;rest&lt;/code&gt; function sets the timer into the resting state:&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;function&lt;/span&gt; &lt;span class="nx"&gt;rest&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;time&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
  &lt;span class="nx"&gt;pomodoroTime&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;time&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nx"&gt;interval&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;setInterval&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;pomodoroTime&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;idle&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="nx"&gt;pomodoroTime&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="p"&gt;},&lt;/span&gt;&lt;span class="mi"&gt;1000&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;It's very similar to an in-progress pomodoro but it sets the pomodoro into an &lt;code&gt;idle&lt;/code&gt; state when the count down finishes. The &lt;code&gt;idle&lt;/code&gt; state can be modelled with this other function:&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;function&lt;/span&gt; &lt;span class="nx"&gt;idle&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;
    &lt;span class="nx"&gt;clearInterval&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;interval&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nx"&gt;pomodoroTime&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;POMODORO_S&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;The whole component looks like this right now:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;script&amp;gt;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;minutesToSeconds&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;minutes&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;minutes&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;60&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;secondsToMinutes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;seconds&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;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;floor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;seconds&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;60&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;padWithZeroes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&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="nx"&gt;number&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;toString&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nx"&gt;padStart&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="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;0&lt;/span&gt;&lt;span class="dl"&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;POMODORO_S&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;minutesToSeconds&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;25&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;LONG_BREAK_S&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;minutesToSeconds&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;20&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;SHORT_BREAK_S&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;minutesToSeconds&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="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;pomodoroTime&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;POMODORO_S&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;completedPomodoros&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="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;interval&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;formatTime&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;timeInSeconds&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;minutes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;secondsToMinutes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;timeInSeconds&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;remainingSeconds&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;timeInSeconds&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="mi"&gt;60&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;padWithZeroes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;minutes&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="nx"&gt;padWithZeroes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;remainingSeconds&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="p"&gt;}&lt;/span&gt;

  &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;startPomodoro&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; 
    &lt;span class="nx"&gt;interval&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;setInterval&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;pomodoroTime&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;completePomodoro&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
      &lt;span class="nx"&gt;pomodoroTime&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="p"&gt;},&lt;/span&gt;&lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;completePomodoro&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;
    &lt;span class="nx"&gt;clearInterval&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;interval&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nx"&gt;completedPomodoros&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="c1"&gt;// TODO: update the current task with a completed pomodoro&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;completedPomodoros&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;rest&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;LONG_BREAK_S&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="nx"&gt;completedPomodoros&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="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;rest&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;SHORT_BREAK_S&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="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;rest&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;time&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
    &lt;span class="nx"&gt;pomodoroTime&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;time&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nx"&gt;interval&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;setInterval&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;pomodoroTime&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;idle&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
      &lt;span class="nx"&gt;pomodoroTime&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="p"&gt;},&lt;/span&gt;&lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;idle&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;
    &lt;span class="nx"&gt;clearInterval&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;interval&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nx"&gt;pomodoroTime&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;POMODORO_S&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;section&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;
    {formatTime(pomodoroTime)}
  &lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;footer&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;on:click=&lt;/span&gt;&lt;span class="s"&gt;{startPomodoro}&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;start&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/footer&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/section&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, when things go wrong and we get distracted we must cancel the pomodoro, write down the cause of our distraction (so we can reflect and learn from it) and start over. Let's update our timer to support this use case.&lt;/p&gt;

&lt;h2&gt;
  
  
  Cancelling a Pomodoro
&lt;/h2&gt;

&lt;p&gt;In order to be able to cancel a pomodoro we'll add a new button to our template:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;section&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;
    {formatTime(pomodoroTime)}
  &lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;footer&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;on:click=&lt;/span&gt;&lt;span class="s"&gt;{startPomodoro}&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;start&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
    &lt;span class="c"&gt;&amp;lt;!-- New button HERE --&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;on:click=&lt;/span&gt;&lt;span class="s"&gt;{cancelPomodoro}&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;cancel&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
    &lt;span class="c"&gt;&amp;lt;!-- END new stuff--&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/footer&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/section&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Whenever the user clicks on this button we'll cancel the current pomodoro using the &lt;code&gt;cancelPomodoro&lt;/code&gt; function:&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;function&lt;/span&gt; &lt;span class="nx"&gt;cancelPomodoro&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;
  &lt;span class="c1"&gt;// TODO: Add some logic to prompt the user to write down&lt;/span&gt;
  &lt;span class="c1"&gt;// the cause of the interruption.&lt;/span&gt;
  &lt;span class="nx"&gt;idle&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;And now we can start and cancel pomodoros:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--3UEdxVFq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://www.barbarianmeetscoding.com/images/svelte-cancel-pomodoro.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--3UEdxVFq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://www.barbarianmeetscoding.com/images/svelte-cancel-pomodoro.gif" title="Starting and cancelling a pomodoro" alt="A pomodoro app with a timer and a series of tasks. The user clicks on start and the pomodoro timer starts its countdown. Then they click on cancel and the pomodor stops." width="800" height="487"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Improving The User Experience Slightly
&lt;/h2&gt;

&lt;p&gt;With our current implementation a user can start a pomodoro when a pomodoro has already started, and likewise cancel a pomodoro which hasn't started yet which makes no sense. Instead the user should get some visual cues as to what actions make sense under the different conditions. So we're going to improve the user experience of our timer by:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Enabling the &lt;em&gt;start pomodoro&lt;/em&gt; button only when we're in an idle state&lt;/li&gt;
&lt;li&gt;Enabling the &lt;em&gt;cancel pomodoro&lt;/em&gt; button only when we're in a pomodoro-in-progress state&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In order to do that we need to keep track of the state of the timer so we start by modeling the different states available with an object:&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;State&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="na"&gt;idle&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;idle&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;inProgress&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;in progress&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;resting&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;resting&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 we'll store the current state of the pomodoro timer in a &lt;code&gt;currentState&lt;/code&gt; variable:&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;currentState&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;State&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;idle&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We then update the different lifecycle methods to update this state as needed:&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;function&lt;/span&gt; &lt;span class="nx"&gt;startPomodoro&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; 
  &lt;span class="nx"&gt;currentState&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;State&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;inProgress&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nx"&gt;interval&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;setInterval&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;pomodoroTime&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;completePomodoro&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="nx"&gt;pomodoroTime&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="p"&gt;},&lt;/span&gt;&lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;rest&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;time&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
  &lt;span class="nx"&gt;currentState&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;State&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;resting&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nx"&gt;pomodoroTime&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;time&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nx"&gt;interval&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;setInterval&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;pomodoroTime&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;idle&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="nx"&gt;pomodoroTime&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="p"&gt;},&lt;/span&gt;&lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;idle&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;
  &lt;span class="nx"&gt;currentState&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;State&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;idle&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nx"&gt;clearInterval&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;interval&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nx"&gt;pomodoroTime&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;POMODORO_S&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;And now we update our templates to take advantage of this new knowledge to enable/disable the buttons that control the timer:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;section&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;
    {formatTime(pomodoroTime)}
  &lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;footer&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;on:click=&lt;/span&gt;&lt;span class="s"&gt;{startPomodoro}&lt;/span&gt; &lt;span class="na"&gt;disabled=&lt;/span&gt;&lt;span class="s"&gt;{currentState&lt;/span&gt; &lt;span class="err"&gt;!==&lt;/span&gt; &lt;span class="na"&gt;State.idle&lt;/span&gt;&lt;span class="err"&gt;}&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;start&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;on:click=&lt;/span&gt;&lt;span class="s"&gt;{cancelPomodoro}&lt;/span&gt; &lt;span class="na"&gt;disabled=&lt;/span&gt;&lt;span class="s"&gt;{currentState&lt;/span&gt; &lt;span class="err"&gt;!==&lt;/span&gt; &lt;span class="na"&gt;State.inProgress&lt;/span&gt;&lt;span class="err"&gt;}&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;cancel&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/footer&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/section&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Awesome!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--mi-LXAPJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://www.barbarianmeetscoding.com/images/svelte-disable-buttons.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--mi-LXAPJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://www.barbarianmeetscoding.com/images/svelte-disable-buttons.gif" title="Buttons are only enabled when it makes sense! Yippi!" alt="A pomodoro app with a timer and a series of tasks. The user clicks on start and the pomodoro timer starts its countdown. Then they click on cancel and the pomodor stops. The buttons are only enabled when it makes sense." width="800" height="487"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The full component at this point looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;script&amp;gt;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;minutesToSeconds&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;minutes&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;minutes&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;60&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;secondsToMinutes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;seconds&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;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;floor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;seconds&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;60&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;padWithZeroes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&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="nx"&gt;number&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;toString&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nx"&gt;padStart&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="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;0&lt;/span&gt;&lt;span class="dl"&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;State&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="na"&gt;idle&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;idle&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;inProgress&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;in progress&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;resting&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;resting&lt;/span&gt;&lt;span class="dl"&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;POMODORO_S&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;minutesToSeconds&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;25&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;LONG_BREAK_S&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;minutesToSeconds&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;20&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;SHORT_BREAK_S&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;minutesToSeconds&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="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;currentState&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;State&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;idle&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;pomodoroTime&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;POMODORO_S&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;completedPomodoros&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="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;interval&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;formatTime&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;timeInSeconds&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;minutes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;secondsToMinutes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;timeInSeconds&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;remainingSeconds&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;timeInSeconds&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="mi"&gt;60&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;padWithZeroes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;minutes&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="nx"&gt;padWithZeroes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;remainingSeconds&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="p"&gt;}&lt;/span&gt;

  &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;startPomodoro&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; 
    &lt;span class="nx"&gt;currentState&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;State&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;inProgress&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nx"&gt;interval&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;setInterval&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;pomodoroTime&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;completePomodoro&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
      &lt;span class="nx"&gt;pomodoroTime&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="p"&gt;},&lt;/span&gt;&lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;completePomodoro&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;
    &lt;span class="nx"&gt;clearInterval&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;interval&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nx"&gt;completedPomodoros&lt;/span&gt;&lt;span class="o"&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;completedPomodoros&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;rest&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;LONG_BREAK_S&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="nx"&gt;completedPomodoros&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="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;rest&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;SHORT_BREAK_S&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="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;rest&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;time&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
    &lt;span class="nx"&gt;currentState&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;State&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;resting&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nx"&gt;pomodoroTime&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;time&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nx"&gt;interval&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;setInterval&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;pomodoroTime&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;idle&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
      &lt;span class="nx"&gt;pomodoroTime&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="p"&gt;},&lt;/span&gt;&lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;cancelPomodoro&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// TODO: Add some logic to prompt the user to write down&lt;/span&gt;
    &lt;span class="c1"&gt;// the cause of the interruption.&lt;/span&gt;
    &lt;span class="nx"&gt;idle&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;idle&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;
    &lt;span class="nx"&gt;currentState&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;State&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;idle&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nx"&gt;clearInterval&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;interval&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nx"&gt;pomodoroTime&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;POMODORO_S&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;section&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;
    {formatTime(pomodoroTime)}
  &lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;footer&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;on:click=&lt;/span&gt;&lt;span class="s"&gt;{startPomodoro}&lt;/span&gt; &lt;span class="na"&gt;disabled=&lt;/span&gt;&lt;span class="s"&gt;{currentState&lt;/span&gt; &lt;span class="err"&gt;!==&lt;/span&gt; &lt;span class="na"&gt;State.idle&lt;/span&gt;&lt;span class="err"&gt;}&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;start&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;on:click=&lt;/span&gt;&lt;span class="s"&gt;{cancelPomodoro}&lt;/span&gt; &lt;span class="na"&gt;disabled=&lt;/span&gt;&lt;span class="s"&gt;{currentState&lt;/span&gt; &lt;span class="err"&gt;!==&lt;/span&gt; &lt;span class="na"&gt;State.inProgress&lt;/span&gt;&lt;span class="err"&gt;}&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;cancel&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
    &lt;span class="c"&gt;&amp;lt;!--button on:click={completePomodoro}&amp;gt;complete&amp;lt;/button--&amp;gt;&lt;/span&gt;

  &lt;span class="nt"&gt;&amp;lt;/footer&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/section&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Adding Some Styling
&lt;/h2&gt;

&lt;p&gt;Now let's apply some styling to our timer. The timer consists on some text with the timer itself and a couple of buttons. The styles of the timer feel like something that should belong to this component and this component only, but the styles of the buttons sound like something that should be consistent across the whole application.&lt;/p&gt;

&lt;p&gt;Styling the timer text is quite straighforward. We just update the styles within &lt;code&gt;PomodoroTimer.svelte&lt;/code&gt;. While I'm doing this, I remember HTML has a &lt;code&gt;time&lt;/code&gt; element that is a more semantic way to represent time in a web application and I switch my puny &lt;code&gt;p&lt;/code&gt; element for &lt;code&gt;time&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;style&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;time&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;block&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;5em&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;font-weight&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;300&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;margin-bottom&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0.2em&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/style&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;section&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;time&amp;gt;&lt;/span&gt;
    {formatTime(pomodoroTime)}
  &lt;span class="nt"&gt;&amp;lt;/time&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;footer&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;on:click=&lt;/span&gt;&lt;span class="s"&gt;{startPomodoro}&lt;/span&gt; &lt;span class="na"&gt;disabled=&lt;/span&gt;&lt;span class="s"&gt;{currentState&lt;/span&gt; &lt;span class="err"&gt;!==&lt;/span&gt; &lt;span class="na"&gt;State.idle&lt;/span&gt;&lt;span class="err"&gt;}&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;start&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;on:click=&lt;/span&gt;&lt;span class="s"&gt;{cancelPomodoro}&lt;/span&gt; &lt;span class="na"&gt;disabled=&lt;/span&gt;&lt;span class="s"&gt;{currentState&lt;/span&gt; &lt;span class="err"&gt;!==&lt;/span&gt; &lt;span class="na"&gt;State.inProgress&lt;/span&gt;&lt;span class="err"&gt;}&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;cancel&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
    &lt;span class="c"&gt;&amp;lt;!--button on:click={completePomodoro}&amp;gt;complete&amp;lt;/button--&amp;gt;&lt;/span&gt;

  &lt;span class="nt"&gt;&amp;lt;/footer&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/section&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And now, for the buttons, how does one do application-wide styles in Svelte? There's &lt;a href="https://css-tricks.com/what-i-like-about-writing-styles-with-svelte/"&gt;different options&lt;/a&gt; but for this particular use case we can take advantage of the &lt;code&gt;global.css&lt;/code&gt; file that is already available in our starter project. In fact, it already has some styles for buttons:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;button&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="m"&gt;#333&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#f4f4f4&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;outline&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;none&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nt"&gt;button&lt;/span&gt;&lt;span class="nd"&gt;:disabled&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="m"&gt;#999&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nt"&gt;button&lt;/span&gt;&lt;span class="nd"&gt;:not&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nd"&gt;:disabled&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="nd"&gt;:active&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#ddd&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nt"&gt;button&lt;/span&gt;&lt;span class="nd"&gt;:focus&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;border-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#666&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;Let's tweak this a little. We're going to have a primary and secondary action buttons, where the primary action is going to be the start pomodoro, and the rest will be treated as secondary action (we really want to get our pomodoros started). The primary action will use a set of &lt;em&gt;accent&lt;/em&gt; colors while the secondary action will use a set of &lt;em&gt;base&lt;/em&gt; colors which we'll define as a color scheme using CSS variables:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nd"&gt;:root&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
 &lt;span class="py"&gt;--black&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#333&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
 &lt;span class="py"&gt;--base&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;white&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
 &lt;span class="py"&gt;--base-light&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#f4f4f4&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
 &lt;span class="py"&gt;--base-dark&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#ddd&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

 &lt;span class="py"&gt;--white&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;white&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
 &lt;span class="py"&gt;--accent&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;orangered&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
 &lt;span class="py"&gt;--accent-light&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#ff4500&lt;/span&gt;&lt;span class="n"&gt;d6&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
 &lt;span class="py"&gt;--accent-dark&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#e83f00&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;Now we redefine the styles for the &lt;strong&gt;secondary action button&lt;/strong&gt; which we'll just act as the default look and feel of a button:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;button&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--base&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nl"&gt;border-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--black&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="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--black&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1.5em&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;font-weight&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;inherit&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;outline&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;none&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;text-transform&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;uppercase&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;transition&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;background-color&lt;/span&gt; &lt;span class="m"&gt;.2s&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;color&lt;/span&gt; &lt;span class="m"&gt;.2s&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;border-color&lt;/span&gt; &lt;span class="m"&gt;.2s&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;opacity&lt;/span&gt; &lt;span class="m"&gt;.2s&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nt"&gt;button&lt;/span&gt;&lt;span class="nd"&gt;:disabled&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;opacity&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0.5&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nt"&gt;button&lt;/span&gt;&lt;span class="nd"&gt;:focus&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
&lt;span class="nt"&gt;button&lt;/span&gt;&lt;span class="nd"&gt;:not&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nd"&gt;:disabled&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="nd"&gt;:hover&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--base-light&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nt"&gt;button&lt;/span&gt;&lt;span class="nd"&gt;:not&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nd"&gt;:disabled&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="nd"&gt;:active&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--base-dark&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;And we define new styles for the &lt;strong&gt;primary action&lt;/strong&gt; button which will build on top of the styles above:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;button&lt;/span&gt;&lt;span class="nc"&gt;.primary&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--accent&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nl"&gt;border-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--accent&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="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--white&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nt"&gt;button&lt;/span&gt;&lt;span class="nc"&gt;.primary&lt;/span&gt;&lt;span class="nd"&gt;:not&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nd"&gt;:disabled&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="nd"&gt;:hover&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--accent-light&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nl"&gt;border-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--accent-light&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nt"&gt;button&lt;/span&gt;&lt;span class="nc"&gt;.primary&lt;/span&gt;&lt;span class="nd"&gt;:not&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nd"&gt;:disabled&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="nd"&gt;:active&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--accent-dark&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nl"&gt;border-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--accent-dark&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;Now to make the inputs fit it with the buttons we'll tweak their font-size:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;input&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nt"&gt;button&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nt"&gt;select&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nt"&gt;textarea&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;font-family&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;inherit&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1.5em&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;font-weight&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;inherit&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="m"&gt;0.4em&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;margin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt; &lt;span class="m"&gt;0.5em&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;box-sizing&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;border-box&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="m"&gt;1px&lt;/span&gt; &lt;span class="nb"&gt;solid&lt;/span&gt; &lt;span class="m"&gt;#ccc&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;border-radius&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;2px&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;We also update the &lt;code&gt;font-weight&lt;/code&gt; of our app to be lighter and more minismalistic because why not:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;body&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="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--black&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nl"&gt;margin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&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="m"&gt;8px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;box-sizing&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;border-box&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;font-family&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;-apple-system&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;BlinkMacSystemFont&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;"Segoe UI"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Roboto&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Oxygen-Sans&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Ubuntu&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Cantarell&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;"Helvetica Neue"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;sans-serif&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;font-weight&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;300&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;We make the add task button in the &lt;code&gt;TaskList.svelte&lt;/code&gt; component also be a primary button:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"primary"&lt;/span&gt; &lt;span class="na"&gt;on:click=&lt;/span&gt;&lt;span class="s"&gt;{addTask}&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Add a new task&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And why not? Let's make the title a little bit bigger (I'm getting carried away here). Inside &lt;code&gt;App.svelte&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;  &lt;span class="nt"&gt;h1&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="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--accent&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nl"&gt;text-transform&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;uppercase&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;6em&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;margin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;font-weight&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100&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;And that's it! We may need to revisit the styles to make sure the contrast is enough to support great accessibility but this is a start:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--WKuLmQlj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://www.barbarianmeetscoding.com/images/svelte-new-styles.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--WKuLmQlj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://www.barbarianmeetscoding.com/images/svelte-new-styles.gif" title="New Styles! Wiho!" alt="A pomodoro app with a timer and a series of tasks. The user clicks on start and the pomodoro timer starts its countdown. Then they click on cancel and the pomodor stops. The buttons are only enabled when it makes sense. The styles have been improved from previous iterations." width="800" height="676"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Sweet!&lt;/strong&gt; And that's all for today. In the next part in the series we'll continue with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Refactoring our timer with the help of automated tests (because I'm not super happy with the current implementation).&lt;/li&gt;
&lt;li&gt;Adding auditory feedback when the pomodoro starts and ends.&lt;/li&gt;
&lt;li&gt;Integrating the timer with the tasks so we have a full pomodoro technique flow.&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;h3&gt;
  
  
  Looking for the source code for the pomodoro app?&lt;/h3&gt;


&lt;p&gt;Look no more! You can find it on &lt;a href="https://github.com/Vintharas/il-pomodoro-in-svelte"&gt;GitHub&lt;/a&gt; ready to be cloned and enjoyed, or on &lt;a href="https://svelte.dev/repl/0ab6485feb3540cc9326716b0e900b19?version=3.16.7"&gt;the Svelte REPL&lt;/a&gt; where you can tinker with it right away.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  More Reflections
&lt;/h2&gt;

&lt;p&gt;Working with Svelte continues to be very pleasant. In addition to my previous reflections (&lt;a href="https://www.barbarianmeetscoding.com/blog/2019/12/27/discovering-svelte-getting-started#some-reflections-so-far"&gt;1&lt;/a&gt;, &lt;a href="https://www.barbarianmeetscoding.com/blog/2019/12/29/discovering-svelte-adding-some-tasks-and-pomodoros#some-more-reflections-so-far"&gt;2&lt;/a&gt;), I've found that:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Formatting functions are very straightforward&lt;/strong&gt;. When I needed to format the time in a specific format in my template, I just went with my gut, wrapped the formatting within a vanilla JavaScript function, used it on the template &lt;code&gt;formatTime(pomodoroTime)}&lt;/code&gt; and it worked.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Assigning and binding properties to a DOM element is also straightforward&lt;/strong&gt;. Once more, I just went with my gut, typed &lt;code&gt;disabled={currentState !== State.idle}&lt;/code&gt; and it worked as I expected it to. Principle of least surprise! Yey!&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Having the styles within a component feels very natural and useful&lt;/strong&gt;: There's no need to switch context as the styles are in close proximity to where they're used. If you ever need to update the styles of a component you know where to go, and likewise if you remove a component its styles disappear with it (You don't need to search around your application in a deadly csshunt).&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>svelte</category>
      <category>javascript</category>
      <category>webdev</category>
    </item>
    <item>
      <title>5 Minutes Vim: Learn to Use Vim's Help</title>
      <dc:creator>Jaime González García</dc:creator>
      <pubDate>Thu, 02 Jan 2020 21:08:43 +0000</pubDate>
      <link>https://dev.to/vintharas/5-minutes-vim-learn-to-use-vim-s-help-327m</link>
      <guid>https://dev.to/vintharas/5-minutes-vim-learn-to-use-vim-s-help-327m</guid>
      <description>&lt;p&gt;&lt;em&gt;This article was originally posted in &lt;a href="https://www.barbarianmeetscoding.com/blog/2020/01/02/5-minutes-vim-learn-to-use-vims-help"&gt;barbarianmeetscoding.com&lt;/a&gt;. 😊&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;In this 5 minutes of Vim goodness we'll learn about one of the most amazing yet often underused features in Vim and how you can use it to &lt;strong&gt;become more effective with Vim&lt;/strong&gt;. &lt;strong&gt;Vim's Help&lt;/strong&gt;! Here we go!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Vim's help is truly amazing and unique.&lt;/strong&gt; If whenever you use Vim you run into a problem, or wonder how to do something, or how something works, try typing &lt;code&gt;:h {keyword}&lt;/code&gt; and Vim will do its best to fulfill your wishes and find the help you need. The &lt;code&gt;{keyword}&lt;/code&gt; itself can be a command, a key combination or just something that you want to learn more about:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Want to know how the &lt;code&gt;:global&lt;/code&gt; command works?&lt;/strong&gt; Then try &lt;code&gt;:h :global&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Want to know what the &lt;code&gt;daw&lt;/code&gt; key combo does?&lt;/strong&gt; Test &lt;code&gt;:h daw&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Want to know about &lt;code&gt;motions&lt;/code&gt; in Vim?&lt;/strong&gt; Then try &lt;code&gt;:h motions&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Want to know what the &lt;code&gt;wildmenu&lt;/code&gt; option does in the vimrc?&lt;/strong&gt; Type &lt;code&gt;:h 'wildmenu'&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Want to learn how to quit Vim?&lt;/strong&gt; Yes. You guessed it. Go &lt;code&gt;:h quit&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Want to learn what &lt;code&gt;CTRL-W&lt;/code&gt; does in insert mode?&lt;/strong&gt; Try &lt;code&gt;:h i_CTRL-W&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;h3&gt;
  
  
  Can't exactly find what you want?&lt;/h3&gt;


&lt;p&gt;Sometimes Vim will have more than one match for the keyword you are searching for. In those cases, Vim will send you to the help page that contains the first match but this might not always be the one you want.&lt;/p&gt;

&lt;p&gt;If you can't seem to find exactly what you are looking for, try the following:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Type &lt;code&gt;:h {keyword}&lt;/code&gt; as usual but don't press &lt;em&gt;ENTER&lt;/em&gt; at the end. Instead type &lt;code&gt;CTRL-D&lt;/code&gt; or &lt;code&gt;TAB&lt;/code&gt;.  That will show you all the occurrences of the keyword within Vim's help and may just reveal what you're truly looking for.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Become More Effective Using Vim's Help
&lt;/h2&gt;

&lt;p&gt;Type &lt;code&gt;:h&lt;/code&gt; or &lt;code&gt;:help&lt;/code&gt; and you'll be taken to the help's index which starts with information about how to use the help itself:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--tZUHTLf2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://www.barbarianmeetscoding.com/images/vim-help.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--tZUHTLf2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://www.barbarianmeetscoding.com/images/vim-help.jpg" title="Vim's awesome help" alt="Vim's awesome help" width="800" height="362"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;How shall I help you, oh master?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;This initial help document contains a quickstart guide with a couple of nice tricks that will allow you navigate Vim's help faster:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Type &lt;strong&gt;&lt;code&gt;&amp;lt;C-]&amp;gt;&lt;/code&gt;&lt;/strong&gt; to follow a link (you can differentiate links from regular text because links are highlighted)&lt;/li&gt;
&lt;li&gt;Use &lt;strong&gt;&lt;code&gt;&amp;lt;C-O&amp;gt;&lt;/code&gt;&lt;/strong&gt; to go back to where you were before&lt;/li&gt;
&lt;li&gt;Use &lt;strong&gt;&lt;code&gt;/{pattern}&lt;/code&gt;&lt;/strong&gt; to search within a document (that's how you normally search for things in Vim by the way).&lt;/li&gt;
&lt;li&gt;The help appears in a normal split window so when you're done with it you can just close it with the &lt;strong&gt;&lt;code&gt;:quit&lt;/code&gt;&lt;/strong&gt; command just like any other window&lt;/li&gt;
&lt;li&gt;Skim &lt;code&gt;:h help-summary&lt;/code&gt; and &lt;code&gt;:h helphelp&lt;/code&gt; at least once to get a feel for all the things that you can search for in Vim and how to do it.&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;Remember! You don't need to know these key combinations by heart. Just remember &lt;code&gt;:help&lt;/code&gt;. Type &lt;code&gt;:help&lt;/code&gt; and you'll be brought to the help about how to use Vim's help where you'll find them again. Help. Help.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Read the Help like a Book
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Vim's help is great for precision lightning attacks of curiosity and/or need&lt;/strong&gt;, like the ones above, but &lt;strong&gt;it is also great to peruse and read like a book&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;When you type &lt;code&gt;help&lt;/code&gt;, right below the quickstart introductory guide, you have the Vim user and reference manuals. The &lt;strong&gt;user manual&lt;/strong&gt; is essentially a book on how to use Vim, from novice to expert with topics ranging from how to move around in Vim to how to create your own syntax highlighters. The &lt;strong&gt;reference manual&lt;/strong&gt; is an in-depth reference of everything Vim. Both of them are really great.&lt;/p&gt;

&lt;h2&gt;
  
  
  Get Help with Vim Plugins
&lt;/h2&gt;

&lt;p&gt;One thing that is really cool is that &lt;strong&gt;Vim's third party plugins also appear in the help&lt;/strong&gt;. Just installed a popular plugin and don't quite know how it works? Try &lt;code&gt;:h {nameOfPlugin}&lt;/code&gt;. If you are unsure about the name of the plugin's docs, then take a look at the bottom of the &lt;code&gt;:help&lt;/code&gt; page where you'll find the third party plugins listed:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--U-ZJt3dC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://www.barbarianmeetscoding.com/images/vim-plugin-help.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--U-ZJt3dC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://www.barbarianmeetscoding.com/images/vim-plugin-help.jpg" title="Vim's awesome help includes plugins" alt="Vim's awesome help includes plugins" width="800" height="340"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The type of information that is really useful to look out for is:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What does it do?&lt;/li&gt;
&lt;li&gt;How do you set it up? Does it work out of the box or does it require some additional setup?&lt;/li&gt;
&lt;li&gt;What are the &lt;strong&gt;commands and mappings&lt;/strong&gt; that it adds to your Vim setup? How can you customize them?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A small warning here: With Vim plugins you will often find that the help you can find inside Vim is far superior to whatever you can find outside (like searching the web). So it is very important to get into the habit of using help, even for plugins, &lt;em&gt;specially&lt;/em&gt; for plugins.&lt;/p&gt;

&lt;blockquote&gt;
&lt;h3&gt;
  
  
  Can't Find The Documentation of a Plugin?
&lt;/h3&gt;

&lt;p&gt;You can load the docs from a plugin using the &lt;code&gt;:helptags ALL&lt;/code&gt; command. But you don't really want to do that manually. Instead, use a plugin manager to load all the docs of your plugins automagically. We will look at how you can do that later in the book.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Awesome! That's it! Hope you found this article useful. Take care!&lt;/p&gt;

</description>
      <category>vim</category>
      <category>neovim</category>
    </item>
    <item>
      <title>5 Minutes Vim: CtrlP considered harmful</title>
      <dc:creator>Jaime González García</dc:creator>
      <pubDate>Wed, 01 Jan 2020 12:07:26 +0000</pubDate>
      <link>https://dev.to/vintharas/5-minutes-vim-ctrlp-considered-harmful-48eg</link>
      <guid>https://dev.to/vintharas/5-minutes-vim-ctrlp-considered-harmful-48eg</guid>
      <description>&lt;p&gt;&lt;em&gt;This article was originally posted in &lt;a href="https://www.barbarianmeetscoding.com/blog/2020/01/01/5-minutes-vim-ctrl-p-considered-harmful"&gt;barbarianmeetscoding.com&lt;/a&gt;. 😊&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;In this 5 minutes of Vim goodness &lt;strong&gt;we'll break the shackles of convention and become slightly more productive when using Vim&lt;/strong&gt;. Here we go!&lt;/p&gt;

&lt;p&gt;Of all the activities you'll perform when coding with Vim (or any other editor), one of the most common ones is the simple act of moving between files. Since this is such a common thing we do in our daily coding using a plugin that allows us to move between files seamlessly is a must-have for all Vim users. &lt;/p&gt;

&lt;p&gt;These plugins fall in the category of &lt;strong&gt;fuzzy search&lt;/strong&gt; file finders and they let you go from a workflow that in Vim can resemble:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The slow typing of a file path using the &lt;code&gt;:edit&lt;/code&gt; command&lt;/li&gt;
&lt;li&gt;The slow navigating of the file tree of your project in &lt;em&gt;netrw&lt;/em&gt; (&lt;code&gt;:h netrw&lt;/code&gt;).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;and in other editors a manual search for a file with the mouse, to something that is so straightforward and instantenous as thinking of the name of a file, typing it and jumping right into it.&lt;/p&gt;

&lt;p&gt;In VSCode it's called quick open and can be reached with &lt;code&gt;CTRL-P&lt;/code&gt; or &lt;code&gt;CMD-P&lt;/code&gt;. In other editors it's called &lt;em&gt;Go To File&lt;/em&gt; or something similar. In Vim there's a slew of plugins that provide a similar (and often more powerful) functionality: &lt;strong&gt;&lt;a href="https://github.com/junegunn/fzf.vim"&gt;fzf.vim&lt;/a&gt;, &lt;a href="https://github.com/ctrlpvim/ctrlp.vim"&gt;ctrlP&lt;/a&gt; and &lt;a href="https://github.com/shougo/denite.nvim"&gt;denite&lt;/a&gt;&lt;/strong&gt; are some of the ones which come to my mind as I type these words.&lt;/p&gt;

&lt;p&gt;I personally use fzf and I use it all the time. The first mapping that I added to my vim fzf configuration was this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight viml"&gt;&lt;code&gt;nnoremap &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;C&lt;span class="p"&gt;-&lt;/span&gt;&lt;span class="k"&gt;p&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;:&amp;lt;&lt;/span&gt;C&lt;span class="p"&gt;-&lt;/span&gt;&lt;span class="k"&gt;u&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;FZF&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;CR&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I probably found it somewhere in the docs and it has served me really well over the years. I just type &lt;code&gt;CTRL-P&lt;/code&gt;, the name of my destination appears in my head, my fingers materialize it into text, and BOOM! I'm in that file.&lt;/p&gt;

&lt;p&gt;All seems fine but when you stop to thing about it... Why use &lt;code&gt;CTRL-P&lt;/code&gt; at all for such a common coding task? It forces me to move both of my pinky fingers away from the home row. That doesn't feel really great, does it? &lt;strong&gt;The answer is probably tradition and inertia&lt;/strong&gt;. I can't quite remember which was the first editor to provide this sort of functionality (textmate?), but we've just continued the tradition and used this key binding when there are far better choices.&lt;/p&gt;

&lt;p&gt;So instead, in order to perform this super frequent task, we can use the premium space in our keyboard, &lt;strong&gt;the home row&lt;/strong&gt;. And we can rely on the &lt;code&gt;&amp;lt;leader&amp;gt;&lt;/code&gt; key so that jumping into fuzzy search is super smooth:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight viml"&gt;&lt;code&gt;nnoremap &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;leader&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;s &lt;span class="p"&gt;:&amp;lt;&lt;/span&gt;C&lt;span class="p"&gt;-&lt;/span&gt;&lt;span class="k"&gt;u&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;FZF&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;CR&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In my vim config &lt;code&gt;&amp;lt;leader&amp;gt;s&lt;/code&gt; is &lt;code&gt;&amp;lt;space&amp;gt;s&lt;/code&gt;. Both of these keys are under my hand in resting position so jumping into fuzzy search mode is completely friction free.&lt;/p&gt;

&lt;p&gt;But this is just an example. The really important thing is the principle behind it:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Question everything&lt;/strong&gt;:  When using plugins or copying mappings from other plugin configurations or vimrcs from other users &lt;strong&gt;question the mappings and commands&lt;/strong&gt;, think about how often you use them, and adapt them before you incorporate them in your own config.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Put frequent tasks in the home row&lt;/strong&gt;: Take advantage of the &lt;code&gt;&amp;lt;leader&amp;gt;&lt;/code&gt; key in combination with the home row keys for frequent coding tasks&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Happy fuzzy finding!&lt;/p&gt;

</description>
      <category>vim</category>
      <category>neovim</category>
    </item>
    <item>
      <title>Goodbye 2019! Hello 2020 Holy Shit!</title>
      <dc:creator>Jaime González García</dc:creator>
      <pubDate>Wed, 01 Jan 2020 01:22:07 +0000</pubDate>
      <link>https://dev.to/vintharas/goodbye-2019-hello-2020-holy-shit-55bp</link>
      <guid>https://dev.to/vintharas/goodbye-2019-hello-2020-holy-shit-55bp</guid>
      <description>&lt;p&gt;&lt;em&gt;This article was originally posted in &lt;a href="https://www.barbarianmeetscoding.com/blog/2019/12/31/goodbye-2019-hello-2020-holy-shit"&gt;barbarianmeetscoding.com&lt;/a&gt;. 😊&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;I cannot believe another year has passed! &lt;strong&gt;And I really can't believe that 2020 is upon us&lt;/strong&gt;. The 2020 of flying cars, hoverboards and deep space exploration. But indeed it has, and that means that it is time for &lt;a href="http://www.barbarianmeetscoding.com/blog/categories/year-summary/"&gt;the traditional reflective year summary&lt;/a&gt;, a wrap-up blog, retrospective of sorts, on what I've achieved the past year, my biggest &lt;em&gt;fails&lt;/em&gt;, what I've learned and what I am planning to do in 2020.&lt;/p&gt;

&lt;p&gt;One of the best things about writing this article is that I will go back and read the ones I wrote the previous years. Which is really, really cool. It's like having a conversation with past Jaime. And it's also really surprising to see how many things happen and can be achieved within the space of a year. Just for these reasons, I encourage you to follow the same practice, even if you don't publish it and it is for your eyes only. It's a really enjoyable habit.&lt;/p&gt;

&lt;p&gt;So! Let's get to it then: &lt;strong&gt;In 2019...&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  In 2019...
&lt;/h2&gt;

&lt;p&gt;2019 was a &lt;strong&gt;very interesting and quite atypical year&lt;/strong&gt;&lt;sup id="fnref1"&gt;1&lt;/sup&gt; in many different ways both in my personal life and at work. If I had to summarize it in a single sentence it would be: &lt;strong&gt;super cozy family year, lots of fun at work, sick and exhausted most of the time yet I got lots of stuff done&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;I &lt;strong&gt;started the year on parental leave&lt;/strong&gt; up until the end of March beginning of April when &lt;strong&gt;Teo started going to kindergarten&lt;/strong&gt; and I went back to work. It was sad and a relief at the same time. I really enjoyed spending so much quality time with my son, but having him start kindergarten was a great experience for the both of us. He got to develop a lot in a very short amount of time, he had a lot of fun meeting new friends and being in a new and very engaging environment, and I got more time for myself and to go back to coding full time which is something I really enjoy doing.&lt;/p&gt;

&lt;p&gt;I &lt;strong&gt;rejoined the &lt;a href="https://gsuite.google.com/products/meet/"&gt;Hangouts Meet&lt;/a&gt; team at Google&lt;/strong&gt; after ~10 months of parental leave with lots of energy and enthusiasm, and it's been a blast to go back to doing software development full time. It took me a while to regain my confidence as a software engineer, but every day, week and month that passed increased my confidence and contributions to the team. By the end of the year, I feel like I became a very strong contributor, leading a lot of initiatives and having a strong impact in what we have delivered. I even started a front-end guild to create a local community around front-end software development in our office in Stockholm, because I love hanging out, sharing ideas about code and encouraging people to learn from each other.&lt;/p&gt;

&lt;p&gt;I am &lt;strong&gt;so very grateful to all the people (my wife Malin and my colleagues at Google) that supported me in me coming back to Software Development&lt;/strong&gt;.  I'm so much more happy and at peace working on something I really enjoy doing and having all the bits within my life align so much better. &lt;strong&gt;Thank you!&lt;/strong&gt;. (If you're curious about this &lt;a href="https://www.barbarianmeetscoding.com/blog/2018/12/12/thoughts-on-interviewing-at-big-tech-companies#google-take-2"&gt;I wrote about it in this article&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;It was a &lt;strong&gt;surprisingly tough year as a parent&lt;/strong&gt;, even though it wasn't as utterly exhausting as the first year it was difficult in a different way. I think the trickiest part has been to balance work and life as a parent and having those two responsibilities weighting on me throughout the day.  That plus &lt;strong&gt;being sick really, really often&lt;/strong&gt; with Teo bringing ultrapowerful germs from kindergarten into the holy sanctuary of our home (It is crazy, I've never been so sick, so often in my life, and I used to be one of those persons who never got sick). In an ideal world I would have plenty of energy for both but I haven't yet cracked that problem and I'd often pass out on the couch now and then after work and after spending some time with Teo. Malin has far more energy than I do, and is a constant inspiration on what it means to be an awesome parent. &lt;strong&gt;Malin is awesome&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;As tough as it is, &lt;strong&gt;it is also wonderful to spend time with my Malin and Teo&lt;/strong&gt;, and following along as Teo grows into an awesome person. The development he's experienced throughout this year has been amazing to behold and ~2 years is my favorite age of his thus far. It has also been really cool to be support him along the way, teach him new things and give him lots of love.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0Co47KU6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://www.barbarianmeetscoding.com/images/2019-fun.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0Co47KU6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://www.barbarianmeetscoding.com/images/2019-fun.jpg" title="Drawing Star Wars!" alt="Jaime and Teo on parental leave drawing star wars with crayons" width="580" height="577"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--vxfxg_Lm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://www.barbarianmeetscoding.com/images/2019-crazy.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vxfxg_Lm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://www.barbarianmeetscoding.com/images/2019-crazy.jpg" title="Jaime and Teo" alt="Jaime and Teo being crazy" width="582" height="578"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--FxF4a0A1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://www.barbarianmeetscoding.com/images/2019-love.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--FxF4a0A1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://www.barbarianmeetscoding.com/images/2019-love.jpg" title="Malin and Teo" alt="Malin and Teo love love" width="578" height="578"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--paR8c-Tc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://www.barbarianmeetscoding.com/images/2019-summer.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--paR8c-Tc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://www.barbarianmeetscoding.com/images/2019-summer.jpg" title="Jaime and Teo. It's hot!" alt="Jaime and Teo on a bench eating oranges under the sun" width="574" height="576"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--FBFXwoqe--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://www.barbarianmeetscoding.com/images/2019-teo.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--FBFXwoqe--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://www.barbarianmeetscoding.com/images/2019-teo.jpg" title="Teo is cool!" alt="Teo being cool with sunglasses" width="576" height="578"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Fw-JXzdA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://www.barbarianmeetscoding.com/images/2019-malin.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Fw-JXzdA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://www.barbarianmeetscoding.com/images/2019-malin.jpg" title="Malin is beautiful!" alt="Malin in Gotland" width="578" height="582"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--aNGqf1S3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://www.barbarianmeetscoding.com/images/2019-books.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--aNGqf1S3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://www.barbarianmeetscoding.com/images/2019-books.jpg" title="Malin and Teo reading" alt="Malin and Teo reading" width="576" height="580"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Et--DC3f--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://www.barbarianmeetscoding.com/images/2019-family.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Et--DC3f--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://www.barbarianmeetscoding.com/images/2019-family.jpg" title="Family time!" alt="Malin, Jaime and Teo hanging out" width="500" height="498"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Work, parenting and exhaustion leave few time and energy to do anything else but &lt;strong&gt;I somehow managed to work on some side projects and community contributions&lt;/strong&gt;. I think that the secret here is that even when the conditions and the environment for doing stuff are quite adverse, &lt;strong&gt;a little bit of consistent work over time produces great results&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Writing
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--KJ2DBBdS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://www.barbarianmeetscoding.com/images/boost-coding-fu-vscode-vim-banner.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--KJ2DBBdS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://www.barbarianmeetscoding.com/images/boost-coding-fu-vscode-vim-banner.jpg" alt="Boost Your Coding Fu With Visual Studio Code and Vim The Book" title="Boost Your Coding Fu With Visual Studio Code and Vim The Book" width="800" height="336"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;I started writing &lt;a href="https://leanpub.com/wizardsusevim"&gt;Wizards Use Vim&lt;/a&gt;, a new and wonderful book on Vim that I couldn't finish in 2019&lt;/strong&gt;. I've been using Vim since 2013, and after a ton of in-depth experimentation with it in 2018 &lt;strong&gt;I embarqued on a quest to make Vim more approachable to everyone&lt;/strong&gt; with my my book &lt;a href="https://leanpub.com/wizardsusevim"&gt;Wizards Use Vim&lt;/a&gt;. I wrote ~200 pages mostly at the beginning of the year, and then I did something strange, I jumped to working on a different book: &lt;a href="https://www.barbarianmeetscoding.com/blog/2019/03/05/boost-your-coding-fu-with-vscode-and-vim-the-book"&gt;Boost Your Coding Fu with VSCode and Vim&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;I wrote and published &lt;a href="https://www.barbarianmeetscoding.com/blog/2019/03/05/boost-your-coding-fu-with-vscode-and-vim-the-book"&gt;Boost Your Coding Fu&lt;/a&gt;&lt;/strong&gt;. The original idea was that &lt;a href="https://www.barbarianmeetscoding.com/blog/2019/03/05/boost-your-coding-fu-with-vscode-and-vim-the-book"&gt;Boost Your Coding Fu&lt;/a&gt; was going to be a very short book, very drafty, like one of those 30 pages books some people give away to get readers subscribed to their blog. But once I started writing it I couldn't help myself, so I wrote it and started improving it, iterating, reviewing, perfecting it some more, and it ended up been a &lt;a href="https://leanpub.com/boostyourcodingfuwithvscodeandvim"&gt;solid and short (140p) book&lt;/a&gt; which I &lt;a href="https://www.barbarianmeetscoding.com/blog/2019/07/25/boost-your-coding-fu-with-vscode-and-vim-is-complete"&gt;completed in July&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;I &lt;strong&gt;built a website for &lt;a href="https://www.barbarianmeetscoding.com/boost-your-coding-fu-with-vscode-and-vim"&gt;Boost Your Coding Fu&lt;/a&gt;&lt;/strong&gt;, with an &lt;strong&gt;&lt;a href="https://www.barbarianmeetscoding.com/boost-your-coding-fu-with-vscode-and-vim/dedication"&gt;online reading experience&lt;/a&gt; open for anybody&lt;/strong&gt; to read, learn and enjoy. I also &lt;strong&gt;recorded &lt;a href="https://www.youtube.com/watch?list=PLWkmatwYW3nE0bhFmV3zxtqHGTowomCRY&amp;amp;v=zQ6Ua-8pM9g"&gt;lots of videos&lt;/a&gt; with step by step VSCodeVim tutorials&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;The &lt;strong&gt;&lt;a href="https://www.barbarianmeetscoding.com/blog/2019/06/24/javascriptmancy-top-100-javascript-books-of-all-time"&gt;JavaScriptmancy Books were in the top 100 JavaScript books of all time&lt;/a&gt;&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Blogging
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;I &lt;strong&gt;redesigned &lt;a href="https://www.barbarianmeetscoding.com/"&gt;Barbarian Meets Coding&lt;/a&gt;&lt;/strong&gt; and added a &lt;a href="https://twitter.com/Vintharas/status/1148653202469838849"&gt;crazy fantasy conan-inspired pixel art animation&lt;/a&gt; to its front page:&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/8KvETIFwKhI"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;I wrote &lt;a href="https://www.barbarianmeetscoding.com/blog/archives"&gt;40 articles in my blog&lt;/a&gt; this year of diverse lengths and topics. This is crazy because I think this is the most articles I've written ever in this blog during a year.

&lt;ul&gt;
&lt;li&gt;There were technical posts on &lt;a href="https://www.barbarianmeetscoding.com/blog/categories/vim"&gt;Vim&lt;/a&gt;, &lt;a href="https://www.barbarianmeetscoding.com/blog/categories/typescript"&gt;TypeScript&lt;/a&gt;, &lt;a href="https://www.barbarianmeetscoding.com/blog/categories/svelte"&gt;Svelte&lt;/a&gt; but also &lt;a href="https://www.barbarianmeetscoding.com/blog/categories/reflection"&gt;soft posts on motivation, focus and career&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;I &lt;a href="https://www.barbarianmeetscoding.com/newsletter/"&gt;redesigned and relaunched my newsletter&lt;/a&gt; with more personal articles, wrote 8 newsletters and when life got pretty tough I kind of paused it.&lt;/li&gt;
&lt;li&gt;In addition to my blog, I put a lot of my content on &lt;a href="https://dev.to/vintharas"&gt;dev.to&lt;/a&gt;, an amazing, warm and super welcoming community for software developers. At the end of the year &lt;strong&gt;I reached 15K subscribers&lt;sup id="fnref2"&gt;2&lt;/sup&gt; which is pretty amazing&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;My &lt;strong&gt;favorite articles&lt;/strong&gt; this year were:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.barbarianmeetscoding.com/blog/2019/01/03/dont-give-up-keep-iterating"&gt;Don't Give Up Keep Iterating&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.barbarianmeetscoding.com/blog/2019/02/08/boost-your-coding-fu-with-vscode-and-vim"&gt;Boost Your Coding Fu With VSCode and Vim&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.barbarianmeetscoding.com/blog/2019/03/02/the-best-way-to-advance-your-career"&gt;The Best Way to Advance Your Career&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.barbarianmeetscoding.com/blog/2019/05/31/exploring-vim-plugins-a-methodology-to-become-1-percent-better-every-week"&gt;Exploring Vim Plugins: A Methodology to Become 1% Better Every Week&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.barbarianmeetscoding.com/blog/2019/08/11/exploring-vim-plugins-improve-and-extend-your-text-objects-with-targets-vim"&gt;Exploring Vim Plugins: Improve and Extend Your Text Objects With targets.vim&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.barbarianmeetscoding.com/blog/2019/12/07/typescript-types-deep-dive-part-i"&gt;TypeScript Types Deep Dive&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.barbarianmeetscoding.com/blog/2019/12/23/discovering-svelte"&gt;Discovering Svelte&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.barbarianmeetscoding.com/blog/2019/12/25/jaimes-guide-to-tmux-the-most-awesome-tool-you-didnt-know-you-needed"&gt;Jaime's Guide to Tmux: The Most Awesome Tool You Didn't know you needed&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.barbarianmeetscoding.com/blog/2019/12/28/polyglot-programming-in-vim"&gt;Polyglot Programming in Vim (or How to Get A Great Developer Experience for Any Language in Vim)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  YouTube
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://www.youtube.com/user/Vintharas/videos?view_as=subscriber"&gt;I created more YouTube content&lt;/a&gt; this year that any other year up until now with 18 videos&lt;/strong&gt;. Creating videos is a ton of fun but it has proved really challenging. Mainly because I've found very hard to find a suitable time to record videos given that I have a toddler around with massive powers of mayhem and destruction, and a light sleep.&lt;/li&gt;
&lt;li&gt;My channel &lt;strong&gt;grew to 278 subscribers&lt;/strong&gt;. Wiho!&lt;/li&gt;
&lt;li&gt;I also tweaked the design of my channel.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Podcasting
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;I created an &lt;a href="https://www.barbarianmeetscoding.com/boost-your-coding-fu-with-vscode-and-vim-podcast#the-podcast"&gt;experimental podcast&lt;/a&gt;&lt;/strong&gt; where I narrate the &lt;a href="https://www.barbarianmeetscoding.com/boost-your-coding-fu-with-vscode-and-vim"&gt;Boost Your Coding Fu With VSCode and Vim&lt;/a&gt; book with a strong yet soothing voice. I completed 7 chapters.&lt;/li&gt;
&lt;li&gt;I &lt;strong&gt;also created a &lt;a href="https://www.barbarianmeetscoding.com/boost-your-coding-fu-with-vscode-and-vim-podcast#the-podcast"&gt;website for the podcast&lt;/a&gt;&lt;/strong&gt; and made it available on iTunes and Google Podcast. &lt;a href="https://www.barbarianmeetscoding.com/wiki/creating-a-podcast/"&gt;I wrote an article on my wiki on how to do that if you want to do the same&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;I was &lt;strong&gt;&lt;a href="https://www.barbarianmeetscoding.com/blog/2019/04/26/i-did-an-interview-for-the-frontmatter-podcast-waaaaat"&gt;interviewed by the Frontmatter podcast&lt;/a&gt;&lt;/strong&gt; about my life, my career at Google, and my experiences as an author.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Speaking and Dev Relations
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;My &lt;strong&gt;&lt;a href="https://www.barbarianmeetscoding.com/speaking/"&gt;speaking contributions&lt;/a&gt; in 2019 were very small&lt;/strong&gt;. This hasn't changed so much since I became a dad. This year I spoke on two events:

&lt;ul&gt;
&lt;li&gt;I was at the &lt;a href="https://www.meetup.com/Stockholm-Google-Developer-Group/events/261023383/"&gt;Google Developer Group Stockholm&lt;/a&gt; speaking about how you can be more productive with &lt;a href="https://www.barbarianmeetscoding.com/boost-your-coding-fu-with-vscode-and-vim"&gt;VSCode and Vim&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;I helped &lt;a href="https://www.meetup.com/Hon-kodar/events/260501178/"&gt;Hon kodar&lt;/a&gt; organize an Angular workshop for women who code or want to learn to code. I delivered two talks and helped throughout the workshops.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In the olden days I didn't have a problem participating or organizing events after work hours, but today with the life of a parent it becomes harder and harder to justify. I just enjoy spending time with my family too much, and supporting my wife in taking care of Teo who can be quite a handful. I think that's a very strong reason why I haven't been doing more of these in-person speaking thingies, it is far easier and more convenient for me to just write or record something when Teo is sleeping.&lt;/p&gt;

&lt;h3&gt;
  
  
  Reading
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;In 2019 I &lt;a href="https://www.barbarianmeetscoding.com/reading/"&gt;read 48 books&lt;/a&gt;&lt;/strong&gt;. I also started and didn't finish dozens more. I wrote an article &lt;a href="https://www.barbarianmeetscoding.com/blog/2019/12/24/my-favorite-books-of-2019"&gt;about my favorite books in 2019&lt;/a&gt;, so if you're looking for new books to read you may want to take a look at that.&lt;/li&gt;
&lt;li&gt;In addition to the above, &lt;a href="https://www.blinkist.com/"&gt;I also "read 23 books" on blinkist&lt;/a&gt;. If you haven't heard about blinkist it's a service where they summarize the most important ideas in very diverse and popular books. I'm not sure if I quite like it yet, sometimes it can feel very superficial, but one thing that I like about it is that it exposes me to lots of ideas that I wouldn't peruse normally because I'd never prioritize that time investment.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  My Biggest Fails of 2019
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Even though it has been a great year overall, this year I felt very often that I was in &lt;strong&gt;survival mode&lt;/strong&gt;, being sick and/or exhausted for long periods of the year. I felt very often that, just as I was about to come back to a good spot of working out, having energy, doing things, something would happen that would knock me back down.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;I left lots of things half-started and unfinished&lt;/strong&gt;: The Wizards Use Vim book jumps right into my mind but also the JavaScript-mancy series have been lacking a lot of attention.&lt;/li&gt;
&lt;li&gt;I tend to spread myself too thin over too many activities and projects.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Exercising and working out hasn't been great this year.&lt;/strong&gt; I've had some good runs throughout the year but combining work, family and working out hasn't really worked out. I so need to get better at this.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;I still downprioritize sleep when I shouldn't&lt;/strong&gt;. This is a constant struggle as a parent when stealing time from sleep hours is the only way you can find some time to invest in yourself.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;We used to travel a lot, but we haven't done much of that this year&lt;/strong&gt;. That's something that I definitely want to go back next year, because it is very enjoyable and I think it's great for Teo to get exposed to different cultures.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  In 2020 I want to...
&lt;/h2&gt;

&lt;p&gt;In 2020 I want to kick ass even more! But we'll talk about that tomorrow. Now it's time to cook a great New Year's Eve dinner. &lt;strong&gt;Happy 2019! And an even happier 2020&lt;/strong&gt;!&lt;/p&gt;




&lt;ol&gt;

&lt;li id="fn1"&gt;
&lt;p&gt;The life of a first-time parent is likely very atypical year after year as your child develops and you get confronted with new challenges and life routines. ↩&lt;/p&gt;
&lt;/li&gt;

&lt;li id="fn2"&gt;
&lt;p&gt;Subscribers are often referred to as followers. But I am not Jesus Christ so I prefer to call them subscribers. e.g. people that are interested in the content that I write and find that content helpful and useful enough to subscribe for more. ↩&lt;/p&gt;
&lt;/li&gt;

&lt;/ol&gt;

</description>
      <category>yearinreview</category>
      <category>personal</category>
    </item>
    <item>
      <title>The Wizard Logs - Part III - The Adventures, Glory and Misfortunes of Writing Wizards Use Vim</title>
      <dc:creator>Jaime González García</dc:creator>
      <pubDate>Mon, 30 Dec 2019 14:33:03 +0000</pubDate>
      <link>https://dev.to/vintharas/the-wizard-logs-part-iii-the-adventures-glory-and-misfortunes-of-writing-wizards-use-vim-3bi9</link>
      <guid>https://dev.to/vintharas/the-wizard-logs-part-iii-the-adventures-glory-and-misfortunes-of-writing-wizards-use-vim-3bi9</guid>
      <description>&lt;p&gt;&lt;em&gt;This article was originally written in &lt;a href="https://www.barbarianmeetscoding.com/blog/2019/12/30/the-wizard-logs-part-iii-the-adventurs-glory-and-misfortunes-of-writing-wizards-use-vim-2020"&gt;barbarianmeetscoding.com&lt;/a&gt;. Cover image credit from media in &lt;a href="https://eu.diablo3.com/en/media/artwork/?view=firefly&amp;amp;keywords=classes.wizard"&gt;diablo 3&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;It has been a looooong time since the &lt;a href="https://www.barbarianmeetscoding.com/blog/2019/01/29/the-wizard-logs-part-ii-the-adventures-glory-and-misfortunes-of-writing-wizards-use-vim"&gt;last time I wrote a wizard log&lt;/a&gt;, yet I haven't been idle. Not quite. But some context may be needed.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.barbarianmeetscoding.com/blog/2019/01/09/wizards-use-vim-my-new-book"&gt;Last year I embarqued on a quest&lt;/a&gt; of sorts: &lt;strong&gt;I wanted to make Vim more approachable to everyone&lt;/strong&gt;. So I started writing &lt;a href="https://leanpub.com/wizardsusevim"&gt;Wizards Use Vim&lt;/a&gt;, an introductory book to Vim that teaches you all you need to know to be an effective Vim user in a fun and light manner.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://leanpub.com/wizardsusevim"&gt;&lt;br&gt;
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ppIe5pw4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://www.barbarianmeetscoding.com/images/book-wizards-use-vim-draft-004.jpg" title="New Cover of Wizards Use Vim" alt="New Cover of Wizards Use VimCan't exit Vim" width="300" height="450"&gt;&lt;br&gt;
&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;But after a couple of months of intense writing I had another idea. If I really wanted to make Vim approachable to developers, I better find developers where they are. And so &lt;strong&gt;I built a bridge towards Vim in the form of a new book: &lt;a href="https://www.barbarianmeetscoding.com/blog/2019/03/05/boost-your-coding-fu-with-vscode-and-vim-the-book"&gt;Boost Your Coding Fu With VSCode and Vim&lt;/a&gt;.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--KJ2DBBdS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://www.barbarianmeetscoding.com/images/boost-coding-fu-vscode-vim-banner.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--KJ2DBBdS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://www.barbarianmeetscoding.com/images/boost-coding-fu-vscode-vim-banner.jpg" alt="Boost Your Coding Fu With Visual Studio Code and Vim The Book" title="Boost Your Coding Fu With Visual Studio Code and Vim The Book" width="800" height="336"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;I started writing Wizards Use Vim to take a break from the JavaScriptmancy Series. Then I started writing a book on VSCodeVim to take a break from Wizards Use Vim. Procrastinator level epic.&lt;/p&gt;

&lt;p&gt;&lt;cite&gt;Jaime. Procrastinator Level Epic.&lt;/cite&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The original idea was that &lt;a href="https://www.barbarianmeetscoding.com/blog/2019/03/05/boost-your-coding-fu-with-vscode-and-vim-the-book"&gt;Boost Your Coding Fu&lt;/a&gt; was going to be a very short book, very drafty, like one of those 30 pages books some people give away to get readers subscribed to their blog. But once I started writing it I couldn't help myself, so I wrote it and started improving it, iterating, reviewing, perfecting it some more, and it ended up been a &lt;a href="https://leanpub.com/boostyourcodingfuwithvscodeandvim"&gt;very solid book&lt;/a&gt; which I &lt;a href="https://www.barbarianmeetscoding.com/blog/2019/07/25/boost-your-coding-fu-with-vscode-and-vim-is-complete"&gt;completed in July&lt;/a&gt; together with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A page to act as a &lt;a href="https://www.barbarianmeetscoding.com/boost-your-coding-fu-with-vscode-and-vim"&gt;hub for the book&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;An &lt;a href="https://www.barbarianmeetscoding.com/boost-your-coding-fu-with-vscode-and-vim/dedication"&gt;online version of the book&lt;/a&gt; open for anybody to read, learn and enjoy&lt;/li&gt;
&lt;li&gt;A &lt;a href="https://www.barbarianmeetscoding.com/boost-your-coding-fu-with-vscode-and-vim/cheatsheet"&gt;cheatsheet&lt;/a&gt; with all the stuff covered within the book&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.youtube.com/watch?list=PLWkmatwYW3nE0bhFmV3zxtqHGTowomCRY&amp;amp;v=zQ6Ua-8pM9g"&gt;Lots of videos&lt;/a&gt; with step by step VSCodeVim tutorials&lt;/li&gt;
&lt;li&gt;An &lt;a href="https://www.barbarianmeetscoding.com/boost-your-coding-fu-with-vscode-and-vim-podcast#the-podcast"&gt;experimental podcast&lt;/a&gt; where I narrate the book&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And had great reviews from readers:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;I simply don't know how to express my fascination about the vscodevim book.&lt;/p&gt;

&lt;p&gt;The only thing that I can say right now is thank you and congratulations.&lt;/p&gt;

&lt;p&gt;I was searching for some vim information and then I found your book, explaining exactly what I needed (cause I'm using vscode lol).&lt;/p&gt;

&lt;p&gt;I brought it for the lowest prize cause I'm not in my better days. Now I finished reading, I wish I could give 3 times more.&lt;/p&gt;
&lt;/blockquote&gt;



&lt;blockquote&gt;
&lt;p&gt;Hey, I just finished reading your book about VSCode and Vim. I read it in 2 days, was a pleasure to read it and also very valuable, I like your way of teaching, definitely works for me.&lt;/p&gt;
&lt;/blockquote&gt;



&lt;blockquote&gt;
&lt;p&gt;Only one chapter in, but I'm already a big fan of &lt;a class="mentioned-user" href="https://dev.to/vintharas"&gt;@vintharas&lt;/a&gt; 's vim vscode book.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;So... Yep. This whole thing kind of derailed a little. What started as the idea for a super short book to help vscode users get a feel for Vim and how it can make you a more productive developer, ended up becoming a shitload of work and content.&lt;/p&gt;

&lt;p&gt;And therefore, with all this time invested in Boost Your Coding Fu plus the super tough life as a parent of a wonderful toddler, &lt;strong&gt;&lt;a href="https://leanpub.com/wizardsusevim"&gt;Wizards Use Vim&lt;/a&gt; has been pretty much frozen&lt;/strong&gt;. Up until now that is! :D For I shall come back to it and finish the shit out of it. This is the current status of the book with 250-ish pages:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Intro. Draft complete&lt;/li&gt;
&lt;li&gt;Part I. Vim Apprentice. Draft complete&lt;/li&gt;
&lt;li&gt;Part II. Vim Master. About 30% draft completed&lt;/li&gt;
&lt;li&gt;Part III. Vim Grandmaster. Only an outline&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;My next goal for the upcoming three months is to:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create a draft for the complete book&lt;/li&gt;
&lt;li&gt;First Review, editing and add exercises&lt;/li&gt;
&lt;li&gt;Second Review, editing and add illustrations&lt;/li&gt;
&lt;li&gt;Complete final cover&lt;/li&gt;
&lt;li&gt;Publish&lt;/li&gt;
&lt;li&gt;Complete full print cover&lt;/li&gt;
&lt;li&gt;Publish in print&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;And that will be my sole focus come 2020. &lt;strong&gt;So hold tight because there's some amazing Vim content coming your way&lt;/strong&gt;  and lots of updates as I progress through these goals.&lt;/p&gt;

</description>
      <category>vim</category>
      <category>webdev</category>
      <category>showdev</category>
    </item>
    <item>
      <title>Learn Svelte: Adding, Editing and Estimating Tasks In The Pomodoro Technique App</title>
      <dc:creator>Jaime González García</dc:creator>
      <pubDate>Sun, 29 Dec 2019 17:34:41 +0000</pubDate>
      <link>https://dev.to/vintharas/discovering-svelte-adding-editing-and-estimating-tasks-in-the-pomodoro-technique-app-26dk</link>
      <guid>https://dev.to/vintharas/discovering-svelte-adding-editing-and-estimating-tasks-in-the-pomodoro-technique-app-26dk</guid>
      <description>&lt;p&gt;&lt;em&gt;This article was originally published on &lt;a href="https://www.barbarianmeetscoding.com/blog/2019/12/29/discovering-svelte-adding-some-tasks-and-pomodoros"&gt;Barbarian Meets Coding&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://svelte.dev/"&gt;Svelte&lt;/a&gt; is a modern web framework that takes a novel approach to building web applications by moving the bulk of its work from runtime to compile-time. Being a compiler-first framework allows Svelte to do some very interesting stuff that is unavailable to other frameworks like disappearing from your application at runtime, or allowing for a component centered development with HTML, JavaScript and CSS coexisting within the same Svelte file in a very web standards friendly fashion.&lt;/p&gt;

&lt;p&gt;In this series we'll follow along as I use Svelte for the first time to build an app. I'll use my go-to project[^1] to learn new frameworks: A &lt;a href="https://francescocirillo.com/pages/pomodoro-technique"&gt;Pomodoro Technique&lt;/a&gt; app, which is a little bit more involved than a TODO list in that it has at least a couple of components (a timer and a list of tasks) that need to interact with each other.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;In this part 3 of the series we continue our project by making it possible to create a list of tasks and estimate the number of pomodoros it will take to perform them. Let's get started!&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Haven't read the other articles in this series? Then you may want to take a look at this &lt;a href="https://www.barbarianmeetscoding.com/blog/2019/12/23/discovering-svelte"&gt;list of resources for getting started with Svelte&lt;/a&gt; or &lt;a href="https://www.barbarianmeetscoding.com/blog/2019/12/27/discovering-svelte-getting-started"&gt;the first part of building the Pomodoro Technique app&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Starting a Daily Pomodoro Routine
&lt;/h2&gt;

&lt;p&gt;When you follow the Pomodoro Technique, the first thing that you'll do everyday before you start working is to sit down and follow these steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Decide what tasks you want to achieve today, &lt;/li&gt;
&lt;li&gt;Estimate how many pomodoros it will take to fulfill them and, then&lt;/li&gt;
&lt;li&gt;Prioritize them taking into account how many pomodoros you can realistically achieve&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Let's improve our skeletal Pomodoro app to support this initial flow by providing a way to create and estimate Tasks.&lt;/p&gt;

&lt;h2&gt;
  
  
  Defining a Way to Model a Task
&lt;/h2&gt;

&lt;p&gt;The first thing that we need to do is to devise a way to model a task. In our current version of the app, a task is just a string that represents a description of whatever we need to get done:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;script&amp;gt;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;tasks&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;plan some fun trip with Teo&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;buy some flowers to my wife&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;write an article about Svelte&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
  &lt;span class="p"&gt;];&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;style&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;ul&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;list-style&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;none&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/style&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;ul&amp;gt;&lt;/span&gt;
  {#each tasks as task}
    &lt;span class="nt"&gt;&amp;lt;li&amp;gt;&lt;/span&gt;{task}&lt;span class="nt"&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
  {/each}
&lt;span class="nt"&gt;&amp;lt;/ul&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But we need our tasks to be slightly more involved with information such as the number of pomodoros we expect the task will take, the status of the task (is it completed or not?) and the actual number of pomodoros the task took.&lt;/p&gt;

&lt;p&gt;So we'll model the task using a class &lt;code&gt;Task&lt;/code&gt; within a new file &lt;code&gt;Task.js&lt;/code&gt; with some initial fields to cover our initial use case:&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="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;Task&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;description&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;""&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;expectedPomodoros&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="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;description&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;description&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;expectedPomodoros&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;expectedPomodoros&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;actualPomodoros&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We can now replace the strings from our original example with instances of this class:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;script&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;afterUpdate&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;svelte&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&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;Task&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;./Task.js&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;tasks&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;Task&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;plan some fun trip with Teo&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;Task&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;buy some flowers to my wife&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;Task&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;write an article about Svelte&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="nt"&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The UI remains the same for now. We've just changed the underlying way in which we represent a task. Now, let's make it possible to add new tasks.&lt;/p&gt;

&lt;h2&gt;
  
  
  Creating new Tasks
&lt;/h2&gt;

&lt;p&gt;Our goal for this tutorial will be to get to a working implementation of a Pomodoro technique app as soon as possible, so we'll focus on getting there fast with little regard for an amazing user experience or great design. We will center our development in getting the basic core functionality in place and later we will polish and refine.&lt;/p&gt;

&lt;p&gt;In order to have a quick implementation of an editable list of tasks where one can add and remove tasks to their heart's content we're going to follow this approach. We'll:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Make all tasks editable by using inputs for each task&lt;/li&gt;
&lt;li&gt;Add a button to add new tasks&lt;/li&gt;
&lt;li&gt;Add a button to remove tasks beside each one of the tasks&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Making Tasks Editable
&lt;/h3&gt;

&lt;p&gt;In order to make our tasks editable we are going to update our &lt;code&gt;TaskList.svelte&lt;/code&gt; component. Instead of plain list elements:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;ul&amp;gt;&lt;/span&gt;
  {#each tasks as task}
    &lt;span class="nt"&gt;&amp;lt;li&amp;gt;&lt;/span&gt;{task}&lt;span class="nt"&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
  {/each}
&lt;span class="nt"&gt;&amp;lt;/ul&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We'll use inputs:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;ul&amp;gt;&lt;/span&gt;
  {#each tasks as task}
    &lt;span class="nt"&gt;&amp;lt;li&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"text"&lt;/span&gt; &lt;span class="na"&gt;value=&lt;/span&gt;&lt;span class="s"&gt;{task.description}&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"number"&lt;/span&gt; &lt;span class="na"&gt;value=&lt;/span&gt;&lt;span class="s"&gt;{task.expectedPomodoros}&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
  {/each}
&lt;span class="nt"&gt;&amp;lt;/ul&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The example above seems like it's working but it really isn't. The &lt;code&gt;value={task.description}&lt;/code&gt; only works one way, from the data into the template. But if a user tries to edit a task, the new description or pomodoros won't be reflected in the data. The way to establish a two-way data binding between data and template is by using the &lt;code&gt;bind:value&lt;/code&gt; directive:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;ul&amp;gt;&lt;/span&gt;
  {#each tasks as task}
    &lt;span class="nt"&gt;&amp;lt;li&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"text"&lt;/span&gt; &lt;span class="na"&gt;bind:value=&lt;/span&gt;&lt;span class="s"&gt;{task.description}&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"number"&lt;/span&gt; &lt;span class="na"&gt;bind:value=&lt;/span&gt;&lt;span class="s"&gt;{task.expectedPomodoros}&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
  {/each}
&lt;span class="nt"&gt;&amp;lt;/ul&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And now we can edit task descriptions and the number of pomodoros we expect each task will take. Whenever we update the underlying data, it will be reflected in the inputs, and likewise, whenever we update the inputs, the changes we do will be reflected in the data.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--K4LrSVcC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://www.barbarianmeetscoding.com/images/svelte-editing-tasks.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--K4LrSVcC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://www.barbarianmeetscoding.com/images/svelte-editing-tasks.jpg" title="We can edit tasks! Yippi!" alt="A big Title 'IL POMODORO' followed by a list of editable tasks within input boxes" width="800" height="421"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's adjust the styles a little bit so that the input fields suit their content better:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;style&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;ul&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;list-style&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;none&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="nc"&gt;.description&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;min-width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;400px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="nc"&gt;.pomodoros&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; 
    &lt;span class="nl"&gt;max-width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/style&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;ul&amp;gt;&lt;/span&gt;
  {#each tasks as task}
    &lt;span class="nt"&gt;&amp;lt;li&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"description"&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"text"&lt;/span&gt; &lt;span class="na"&gt;bind:value=&lt;/span&gt;&lt;span class="s"&gt;{task.description}&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"pomodoros"&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"number"&lt;/span&gt; &lt;span class="na"&gt;bind:value=&lt;/span&gt;&lt;span class="s"&gt;{task.expectedPomodoros}&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
  {/each}
&lt;span class="nt"&gt;&amp;lt;/ul&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Svelte styles are scoped to the component itself so I could've styled the &lt;code&gt;input&lt;/code&gt; elements directly (with &lt;code&gt;nth-child&lt;/code&gt; selectors for instance), but I like to use semantic named classes for two reasons:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;They are easier to read and make sense of&lt;/li&gt;
&lt;li&gt;If I happen to change the order of the inputs at some point in the future I won't break the styles of my app&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now it looks better! Nice!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--iPT-ANon--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://www.barbarianmeetscoding.com/images/svelte-edit-tasks-improved.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--iPT-ANon--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://www.barbarianmeetscoding.com/images/svelte-edit-tasks-improved.jpg" title="Now the styles look better!" alt="A big Title 'IL POMODORO' followed by a list of editable tasks within input boxes" width="800" height="362"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Adding New Tasks
&lt;/h3&gt;

&lt;p&gt;The next thing we want to do is to be able to add new tasks. So we add a button that will perform that function:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;ul&amp;gt;&lt;/span&gt;
  {#each tasks as task}
    &lt;span class="nt"&gt;&amp;lt;li&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"description"&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"text"&lt;/span&gt; &lt;span class="na"&gt;bind:value=&lt;/span&gt;&lt;span class="s"&gt;{task.description}&lt;/span&gt; &lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"pomodoros"&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"number"&lt;/span&gt; &lt;span class="na"&gt;bind:value=&lt;/span&gt;&lt;span class="s"&gt;{task.expectedPomodoros}&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
  {/each}
  &lt;span class="nt"&gt;&amp;lt;button&amp;gt;&lt;/span&gt;Add a new task&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/ul&amp;gt;&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Whenever we click on this button we will add a task to the list of tasks that we want to complete today. In order to do that, we handle the click event using the &lt;code&gt;on:{event}&lt;/code&gt; directive so that every time a user clicks on that button a new task is created and added to our list:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;on:click=&lt;/span&gt;&lt;span class="s"&gt;{addTask}&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Add a new task&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;addTask&lt;/code&gt; function belongs to the behavior-y portion of our Svelte component inside the &lt;code&gt;script&lt;/code&gt; tag:&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;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;afterUpdate&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;svelte&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&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;Task&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;./Task.js&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;tasks&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;Task&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;plan some fun trip with Teo&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;Task&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;buy some flowers to my wife&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;Task&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;write an article about Svelte&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="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;addTask&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;
    &lt;span class="nx"&gt;tasks&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;Task&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And now when I click on the button to add a new task... &lt;strong&gt;nothing happens&lt;/strong&gt;. Hmm...&lt;/p&gt;

&lt;p&gt;After some tinkering and troubleshooting I realized that the way Svelte knows whether something changes is through a new assignment. So we need to update our code above to the following:&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;function&lt;/span&gt; &lt;span class="nx"&gt;addTask&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;
  &lt;span class="nx"&gt;tasks&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;tasks&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;concat&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;Task&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 also learnt some interesting things:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Svelte has nice support for sourcemaps so I can look at Svelte code in Chrome Dev Tools. However, I cannot set a break point or use &lt;a href="https://developers.google.com/web/updates/2019/01/devtools"&gt;logpoints&lt;/a&gt; inside the &lt;code&gt;addTask&lt;/code&gt; method.&lt;/li&gt;
&lt;li&gt;With the aid of &lt;code&gt;console.log&lt;/code&gt; inside &lt;code&gt;addTask&lt;/code&gt; and the &lt;code&gt;{@debug tasks}&lt;/code&gt; on the Svelte template I could see how the list kept growing but the template was never updated. After fixing the issue, as the list kept growing the &lt;code&gt;{@debug tasks}&lt;/code&gt; was executed and logged the updated list of tasks.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;script&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;Task&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;./Task.js&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;tasks&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;Task&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;plan some fun trip with Teo&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;Task&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;buy some flowers to my wife&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;Task&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;write an article about Svelte&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="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;addTask&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;
    &lt;span class="nx"&gt;tasks&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;Task&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;tasks&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// =&amp;gt; this grows everytime&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;

&lt;span class="c"&gt;&amp;lt;!-- this was only executed the first time --&amp;gt;&lt;/span&gt;
{@debug tasks}
&lt;span class="nt"&gt;&amp;lt;ul&amp;gt;&lt;/span&gt;
  {#each tasks as task}
    &lt;span class="nt"&gt;&amp;lt;li&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"description"&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"text"&lt;/span&gt; &lt;span class="na"&gt;bind:value=&lt;/span&gt;&lt;span class="s"&gt;{task.description}&lt;/span&gt; &lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"pomodoros"&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"number"&lt;/span&gt; &lt;span class="na"&gt;bind:value=&lt;/span&gt;&lt;span class="s"&gt;{task.expectedPomodoros}&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
  {/each}
  &lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;on:click=&lt;/span&gt;&lt;span class="s"&gt;{addTask}&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Add a new task&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/ul&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;It is very easy to inspect the generated code both within &lt;a href="https://svelte.dev/repl/06fd5ef1f33943c2bd6eed8abe0f29c6?version=3.16.7"&gt;the Svelte Playground&lt;/a&gt; or when developing Svelte locally. The output JavaScript produced for pushing a task in the existing array is:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;addTask&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;tasks&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;Task&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;Whereas if we update the value of the &lt;code&gt;tasks&lt;/code&gt; variable the following code is generated:&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;function&lt;/span&gt; &lt;span class="nx"&gt;addTask&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;$$invalidate&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="nx"&gt;tasks&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;tasks&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;concat&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;Task&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;That &lt;code&gt;$$invalidate&lt;/code&gt; function must be the one that warns Svelte that data has changed and that the template (the part that depends on &lt;code&gt;tasks&lt;/code&gt;) needs to be re-rendered.&lt;/p&gt;

&lt;p&gt;Anyhow! Now we can add new tasks:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--uRcPVgnf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://www.barbarianmeetscoding.com/images/svelte-add-new-task.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--uRcPVgnf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://www.barbarianmeetscoding.com/images/svelte-add-new-task.jpg" title="Now we can add tasks" alt="A big Title 'IL POMODORO' followed by a list of editable tasks within input boxes. There's a button to add new tasks." width="800" height="422"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Removing Existing Tasks
&lt;/h3&gt;

&lt;p&gt;We can add tasks, so we should also be able to remove tasks whenever we change our priorities. In order to do that, we add a new button for each task:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;ul&amp;gt;&lt;/span&gt;
  {#each tasks as task}
    &lt;span class="nt"&gt;&amp;lt;li&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"description"&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"text"&lt;/span&gt; &lt;span class="na"&gt;bind:value=&lt;/span&gt;&lt;span class="s"&gt;{task.description}&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"pomodoros"&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"number"&lt;/span&gt; &lt;span class="na"&gt;bind:value=&lt;/span&gt;&lt;span class="s"&gt;{task.expectedPomodoros}&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="c"&gt;&amp;lt;!-- NEW STUFF --&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;on:click=&lt;/span&gt;&lt;span class="s"&gt;{()&lt;/span&gt; &lt;span class="err"&gt;=&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt; removeTask(task)}&amp;gt;X&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
      &lt;span class="c"&gt;&amp;lt;!-- END NEW STUFF --&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
  {/each}
  &lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;on:click=&lt;/span&gt;&lt;span class="s"&gt;{addTask}&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Add a new task&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/ul&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And create a new &lt;code&gt;removeTask&lt;/code&gt; method to perform the actual removing:&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;function&lt;/span&gt; &lt;span class="nx"&gt;removeTask&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;task&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;index&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;tasks&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;indexOf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;task&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nx"&gt;tasks&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[...&lt;/span&gt;&lt;span class="nx"&gt;tasks&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;slice&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="nx"&gt;index&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="p"&gt;...&lt;/span&gt;&lt;span class="nx"&gt;tasks&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;slice&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;index&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="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;JavaScript should really have an &lt;code&gt;array.prototype.remove&lt;/code&gt; method... FizzBuzz it, let's do it (&lt;strong&gt;one should never, ever do this at home or work. Only on hobby projects with zero stakes&lt;/strong&gt;). &lt;/p&gt;

&lt;p&gt;I add a new &lt;code&gt;ArrayExtensions.js&lt;/code&gt; file with this beautiful thing:&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="cm"&gt;/**
 * Returns a new array without the item passed as an argument
 */&lt;/span&gt;
&lt;span class="nb"&gt;Array&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;prototype&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;remove&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;item&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;index&lt;/span&gt; &lt;span class="o"&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;indexOf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;item&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="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;slice&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="nx"&gt;index&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="nx"&gt;slice&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;index&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="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And update our &lt;code&gt;TaskList.svelte&lt;/code&gt; component:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;script&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;afterUpdate&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;svelte&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&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;Task&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;./Task.js&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./ArrayExtensions.js&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;tasks&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;Task&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;plan some fun trip with Teo&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;Task&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;buy some flowers to my wife&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;Task&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;write an article about Svelte&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="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;addTask&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;
    &lt;span class="nx"&gt;tasks&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;tasks&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;concat&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;Task&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;removeTask&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;task&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
    &lt;span class="c1"&gt;// It looks way nicer, doesn't it?&lt;/span&gt;
    &lt;span class="nx"&gt;tasks&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;tasks&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;remove&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;task&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And now tasks can be removed:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--2bT76yNA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://www.barbarianmeetscoding.com/images/svelte-remove-task.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--2bT76yNA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://www.barbarianmeetscoding.com/images/svelte-remove-task.jpg" title="Now we can remove tasks!" alt="A big Title 'IL POMODORO' followed by a list of editable tasks within input boxes. There's a button to add new tasks." width="800" height="392"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  A Slightly Better User Experience Using Svelte Lifecycle Hooks
&lt;/h2&gt;

&lt;p&gt;Wouldn't it be nice if the newly created task description would come into focus when a new task is created? That way the keyboard friendly user of our app could press Enter on the &lt;em&gt;Add new task&lt;/em&gt; button, type away the task and estimation, press Enter again on the button, and so forth. &lt;strong&gt;Maximum productivity&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;In order to be able to add this type of functionality we need to know when a new input is added to the DOM, and have that new input get the focus. After taking a quick look at the Svelte docs I found that you can hook into the lifecycle of a component to solve this sort of things. The &lt;em&gt;afterUpdate&lt;/em&gt; lifecycle hook is the one that's executed after the DOM has been updated with new data, so that sounds like a good candidate:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;script&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;afterUpdate&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;svelte&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&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;Task&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;./Task.js&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./ArrayExtensions.js&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="c1"&gt;// Rest of the code has been collapsed for simplicity's sake&lt;/span&gt;

  &lt;span class="nx"&gt;afterUpdate&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;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;Hello! I was updated!&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="nt"&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If we take a look at our app right now we'll see how every time the component is rendered we get that message printed in the console. Now we need to get a reference to that input element that gets created. Svelte has a special directive that may help with that &lt;code&gt;bind:this&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;You can use it like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;script&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;afterUpdate&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;svelte&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&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;Task&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;./Task.js&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./ArrayExtensions.js&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;lastInput&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="c1"&gt;// rest of the code collapsed for simplicity's sake&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;style&amp;gt;&lt;/span&gt;
&lt;span class="c"&gt;/** styles collapsed **/&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/style&amp;gt;&lt;/span&gt;


&lt;span class="nt"&gt;&amp;lt;ul&amp;gt;&lt;/span&gt;
  {#each tasks as task}
    &lt;span class="nt"&gt;&amp;lt;li&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"description"&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"text"&lt;/span&gt; &lt;span class="na"&gt;bind:value=&lt;/span&gt;&lt;span class="s"&gt;{task.description}&lt;/span&gt; 
       &lt;span class="na"&gt;bind:this=&lt;/span&gt;&lt;span class="s"&gt;{lastInput}&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;  &lt;span class="c"&gt;&amp;lt;!-- THIS IS NEW! --&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"pomodoros"&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"number"&lt;/span&gt; &lt;span class="na"&gt;bind:value=&lt;/span&gt;&lt;span class="s"&gt;{task.expectedPomodoros}&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;on:click=&lt;/span&gt;&lt;span class="s"&gt;{()&lt;/span&gt; &lt;span class="err"&gt;=&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt; removeTask(task)}&amp;gt;X&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
  {/each}
  &lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;on:click=&lt;/span&gt;&lt;span class="s"&gt;{addTask}&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Add a new task&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/ul&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And now that we have a reference to that input we can use it to make it come into focus when we create a new task:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;script&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;afterUpdate&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;svelte&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&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;Task&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;./Task.js&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./ArrayExtensions.js&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;taskAddedPendingFocus&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;lastInput&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;tasks&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;Task&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;plan some fun trip with Teo&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;Task&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;buy some flowers to my wife&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;Task&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;write an article about Svelte&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="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;addTask&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;
    &lt;span class="nx"&gt;tasks&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;tasks&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;concat&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;Task&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;
    &lt;span class="nx"&gt;taskAddedPendingFocus&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;removeTask&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;task&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
    &lt;span class="nx"&gt;tasks&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;tasks&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;remove&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;task&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;focusNewTask&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;taskAddedPendingFocus&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;lastInput&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;lastInput&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;focus&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
      &lt;span class="nx"&gt;taskAddedPendingFocus&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;false&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;afterUpdate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;focusNewTask&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This solution seems quite brittle for several reasons, like the fact that I have an nagging feeling that I can only get away with it because the newly created input is the last input in the DOM. But it will work for now. Sometimes the right solution is the working solution. We shall pay our accrued technical debt soon enough. &lt;/p&gt;

&lt;p&gt;For the time being, enjoy with a nice focus behavior:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--lf_T0iOF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://www.barbarianmeetscoding.com/images/svelte-focus.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--lf_T0iOF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://www.barbarianmeetscoding.com/images/svelte-focus.gif" title="Creating tasks with nice focus" alt="An animated gif that shows me adding new tasks to a to do list and keeping focus in the description field." width="600" height="389"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Setting a Goal of Pomodoros for the Day and Keeping it
&lt;/h2&gt;

&lt;p&gt;The final thing that we want to add to support the pomodoro startup flow is to have a way for the user to understand how many pomodoros they're comitting themselves to complete. A quick way to do that is to just sum all the estimated pomodoros for all tasks and show them to the user. &lt;/p&gt;

&lt;p&gt;This is a perfect feature because it's simple and it lets us experiment with the reactivity system in Svelte.&lt;/p&gt;

&lt;p&gt;In Svelte, you can create properties that are computed from other existing properties. In this case, we need a new property that is the sum all of current pomodoros for all tasks. Such a property could look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;script&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;afterUpdate&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;svelte&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&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;Task&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;./Task.js&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./ArrayExtensions.js&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;taskAddedPendingFocus&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;lastInput&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;tasks&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;Task&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;plan some fun trip with Teo&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;Task&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;buy some flowers to my wife&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;Task&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;write an article about Svelte&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="nl"&gt;$&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;allExpectedPomodoros&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;tasks&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;reduce&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;acc&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;t&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;acc&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;t&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;expectedPomodoros&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="cm"&gt;/** rest of the code omitted for the sake of clarity. **/&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;$:&lt;/code&gt; syntax tells Svelte that the &lt;code&gt;allExpectedPomodoros&lt;/code&gt; property is a reactive value, and that it needs to be updated any time &lt;code&gt;tasks&lt;/code&gt; is updated (The funny thing is that this is actual &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/label"&gt;valid syntax in JavaScript&lt;/a&gt; which I've never used in my life).&lt;/p&gt;

&lt;p&gt;Now we can add it to our markup:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;ul&amp;gt;&lt;/span&gt;
  {#each tasks as task}
    &lt;span class="nt"&gt;&amp;lt;li&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"description"&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"text"&lt;/span&gt; &lt;span class="na"&gt;bind:value=&lt;/span&gt;&lt;span class="s"&gt;{task.description}&lt;/span&gt; &lt;span class="na"&gt;bind:this=&lt;/span&gt;&lt;span class="s"&gt;{lastInput}&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"pomodoros"&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"number"&lt;/span&gt; &lt;span class="na"&gt;bind:value=&lt;/span&gt;&lt;span class="s"&gt;{task.expectedPomodoros}&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;on:click=&lt;/span&gt;&lt;span class="s"&gt;{()&lt;/span&gt; &lt;span class="err"&gt;=&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt; removeTask(task)}&amp;gt;X&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
  {/each}
  &lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;on:click=&lt;/span&gt;&lt;span class="s"&gt;{addTask}&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Add a new task&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/ul&amp;gt;&lt;/span&gt;
&lt;span class="c"&gt;&amp;lt;!-- New stuff here --&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;
  Today you'll complete {allExpectedPomodoros} pomodoros.
&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And we are done!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--WznumjnS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://www.barbarianmeetscoding.com/images/svelte-total-pomodoros.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--WznumjnS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://www.barbarianmeetscoding.com/images/svelte-total-pomodoros.gif" title="Creating tasks with nice focus" alt="An animated gif that shows me adding new tasks to a to do list and keeping focus in the description field." width="600" height="350"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  And What happens When There's no Tasks?
&lt;/h2&gt;

&lt;p&gt;Ok, just one more thing. There's one last detail that'd be nice to have work out. What happens when there are no tasks? &lt;/p&gt;

&lt;p&gt;Right now we just show an empty void of nothingness but it'd be nice to show some encouraging message to our users to have them start the day with strength. Let's do that!&lt;/p&gt;

&lt;p&gt;We can take advantage of Svelte's &lt;code&gt;{#if} and {:else}&lt;/code&gt; blocks to show a message when there are no tasks yet. For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;{#if tasks.length === 0}
  &lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;You haven't added any tasks yet. You can do it! Add new tasks and start kicking some butt!&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
{:else}
  &lt;span class="nt"&gt;&amp;lt;ul&amp;gt;&lt;/span&gt;
    {#each tasks as task}
      &lt;span class="nt"&gt;&amp;lt;li&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"description"&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"text"&lt;/span&gt; &lt;span class="na"&gt;bind:value=&lt;/span&gt;&lt;span class="s"&gt;{task.description}&lt;/span&gt; &lt;span class="na"&gt;bind:this=&lt;/span&gt;&lt;span class="s"&gt;{lastInput}&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"pomodoros"&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"number"&lt;/span&gt; &lt;span class="na"&gt;bind:value=&lt;/span&gt;&lt;span class="s"&gt;{task.expectedPomodoros}&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;on:click=&lt;/span&gt;&lt;span class="s"&gt;{()&lt;/span&gt; &lt;span class="err"&gt;=&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt; removeTask(task)}&amp;gt;X&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
    {/each}
  &lt;span class="nt"&gt;&amp;lt;/ul&amp;gt;&lt;/span&gt;
{/if}

&lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;on:click=&lt;/span&gt;&lt;span class="s"&gt;{addTask}&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Add a new task&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;

{#if tasks.length != 0}
  &lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;
    Today you'll complete {allExpectedPomodoros} pomodoros.
  &lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
{/if}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--miLB3Zd5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://www.barbarianmeetscoding.com/images/svelte-you-can-do-it.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--miLB3Zd5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://www.barbarianmeetscoding.com/images/svelte-you-can-do-it.jpg" title="An inspiring message for when there are no tasks" alt="An inspiring message for when the user hasn't created any tasks yet" width="800" height="275"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;h3&gt;
  
  
  Looking for the source code for the pomodoro app?
&lt;/h3&gt;

&lt;p&gt;Look no more! You can find it on &lt;a href="https://github.com/Vintharas/il-pomodoro-in-svelte"&gt;GitHub&lt;/a&gt; ready to be cloned and enjoyed, or on &lt;a href="https://svelte.dev/repl/06fd5ef1f33943c2bd6eed8abe0f29c6?version=3.16.7"&gt;the Svelte REPL&lt;/a&gt; where you can tinker with it right away.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Some More Reflections So Far
&lt;/h2&gt;

&lt;p&gt;In general, working with Svelte has been quite pleasant. Here are some more thoughts to add to &lt;a href="https://www.barbarianmeetscoding.com/blog/2019/12/27/discovering-svelte-getting-started#some-reflections-so-far"&gt;the ones from the last article&lt;/a&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;In general things still work mostly as I expect them to work and it is easy to troubleshoot and recover from errors&lt;/strong&gt;. I was surprised that &lt;code&gt;array.push&lt;/code&gt; didn't trigger a component render but after diving into the issue I understand that it is much easier for the compiler to understand that changes happen on assignments. And it does make a lot of sense, it easier to think of having to update the values of things instead of learning a new API (like &lt;code&gt;setState&lt;/code&gt; for instance).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;It was a pity that I couldn't put breakpoints or logpoints in the &lt;code&gt;svelte&lt;/code&gt; code in Chrome Dev Tools&lt;/strong&gt;. I really expected that to work but perhaps it requires some additional setup that I am unaware of. It does feel like &lt;strong&gt;something that should be supported in a dev environment out of the box&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;It is really cool that the Svelte tutorials and the playground provide access to the code generated by the Svelte compiler&lt;/strong&gt;. It was fun to take a peek into the generated code and realize that the array.push wasn't generating an invalidating call. (This also shows that Svelte does have a runtime, albeit small, even though people often market it as completely disappearing once your app has been generated).&lt;/li&gt;
&lt;li&gt;The syntax for handling events, binding elements to data, the if and else blocks, it was non standard but quite reminiscent at times, and in general &lt;strong&gt;easy to learn&lt;/strong&gt;. (Although that may be because of the experience I have with many other frameworks that implement similar capabilities with slightly different syntax)&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;$:&lt;/code&gt; reactive values are really easy to implement and render in your component.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And we have come to an end for today. Hope you enjoyed this article! Take care!&lt;/p&gt;

</description>
      <category>svelte</category>
      <category>javascript</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
