<?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: Favour George</title>
    <description>The latest articles on DEV Community by Favour George (@phavor).</description>
    <link>https://dev.to/phavor</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%2F79502%2Fea866bac-5618-4594-8573-d64ac4acfb7f.jpeg</url>
      <title>DEV Community: Favour George</title>
      <link>https://dev.to/phavor</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/phavor"/>
    <language>en</language>
    <item>
      <title>Infinite Gallery Viewer with Typescript</title>
      <dc:creator>Favour George</dc:creator>
      <pubDate>Fri, 23 Oct 2020 13:24:47 +0000</pubDate>
      <link>https://dev.to/phavor/infinite-gallery-viewer-with-typescript-1l7i</link>
      <guid>https://dev.to/phavor/infinite-gallery-viewer-with-typescript-1l7i</guid>
      <description>&lt;p&gt;In our previous series release &lt;a href="https://kodeinstincts.hashnode.dev/build-a-quote-generator-with-typescript-1"&gt;Build a quote generator with typescript&lt;/a&gt;, we converted a regular &lt;code&gt;Javascript&lt;/code&gt; code to &lt;code&gt;Typescript&lt;/code&gt;, and it was fun. In today's release, we'd be converting an Infinite Gallery viewer built with &lt;code&gt;Javascript&lt;/code&gt; to &lt;code&gt;Typescript&lt;/code&gt;.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Disclaimer: This article is part of &lt;code&gt;ZTM&lt;/code&gt; &lt;a href="https://udemy.com/course/javascript-web-projects-to-build-your-portfolio-resume/"&gt;Andre Negeoi's&lt;/a&gt; Portfolio enhancement course&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The Javascript codebase is on &lt;a href="https://github.com/phavor/HacksPanel/tree/main/inScroll"&gt;GitHub&lt;/a&gt;. You should obtain the site structure and stylesheet from there. We'd focus on the &lt;code&gt;Typescript&lt;/code&gt; conversion here.&lt;/p&gt;

&lt;h3&gt;
  
  
  Setup Typescript
&lt;/h3&gt;

&lt;p&gt;If you need help setting up your Typescript environment for this exercise, see the setup from our last series &lt;a href="https://kodeinstincts.hashnode.dev/build-a-quote-generator-with-typescript-1"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Getting an Unsplash API key
&lt;/h3&gt;

&lt;p&gt;Head on to &lt;a href="https://unsplash.com/join"&gt;Unsplash&lt;/a&gt; and register, next click on &lt;code&gt;api/developers&lt;/code&gt; tab from the profile menu, then click on &lt;code&gt;Your apps&lt;/code&gt;. Follow the guide to create a new app and get your API_KEY.&lt;/p&gt;

&lt;h3&gt;
  
  
  Writing the App.ts
&lt;/h3&gt;

&lt;p&gt;Let's start with our variables and interface definitions:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const imageContainer = document.getElementById('image-container');
const loader = document.getElementById('loader');

let photosArray: GalleryData[];
let ready = false;
let imagesLoaded = 0;
let totalImages = 0;
let count = 5;
const API_KEY = &amp;lt;your_api_key&amp;gt;;
let API_URL = `https://api.unsplash.com/photos/random/?client_id=${API_KEY}&amp;amp;count=${count}
`;

interface GalleryData {
  alt_description: string;
  urls: {
    regular: string;
  };
  links: {
    html: string;
  }
}

interface Attribute {
  src?: string;
  alt?: string;
  href?: string;
  title?: string;
  target?: string;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  The functions
&lt;/h3&gt;

&lt;p&gt;Our first function would be the &lt;code&gt;imageLoaded&lt;/code&gt; function.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Check if all images were loaded
function imageLoaded() {
  imagesLoaded++;

  if (imagesLoaded === totalImages) {
    ready = true;
    loader!.hidden = true;
    count = 30;
    API_URL = `https://api.unsplash.com/photos/random/?client_id=${API_KEY}&amp;amp;count=${count}
`;
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The special conversion highlight here is &lt;code&gt;loader!.hidden = true&lt;/code&gt;; When we defined the &lt;code&gt;loader&lt;/code&gt; element initially with this &lt;code&gt;const loader = document.getElementById('loader');&lt;/code&gt;, we could either have the &lt;code&gt;HTMLElement&lt;/code&gt; or &lt;code&gt;null&lt;/code&gt;. To tell typescript that we are sure that the element exists on the page, we use the &lt;code&gt;!&lt;/code&gt; before the element name. That overrides typescript's strict null check.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Pro-Tip&lt;/strong&gt;: Use only when you are double sure that the element exists on the page and will not be removed throughout the lifetime of your code.&lt;/p&gt;

&lt;h4&gt;
  
  
  setAttribute Helper function
&lt;/h4&gt;

&lt;p&gt;This function will help us stay &lt;code&gt;DRY&lt;/code&gt;. Typescript warns when we do not type our parameters. Our function would need&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A HTMLElement to set the attributes against, this will be the first parameter.&lt;/li&gt;
&lt;li&gt;An object that contains the attributes we want to set and their values.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Helper function to set attributes on DOM elements
function setAttributes(element: HTMLElement, attributes: Attribute) {
  for (const [key, value] of Object.entries(attributes as Record&amp;lt;string, string&amp;gt;)) {
    element.setAttribute(key, value);
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Pro Tip: To use &lt;code&gt;Object.entries&lt;/code&gt;, ensure you add &lt;code&gt;"ES2017"&lt;/code&gt; or later to your &lt;code&gt;tsconfig.json&lt;/code&gt;'s lib.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h4&gt;
  
  
  displayPhotos function
&lt;/h4&gt;

&lt;p&gt;The &lt;code&gt;displayPhotos&lt;/code&gt; function generates the DOM elements and renders it to the screen.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Display photos
const displayPhotos = () =&amp;gt; {
  totalImages = photosArray.length;
  imagesLoaded = 0;

  photosArray.forEach(photo =&amp;gt; {
    // Create &amp;lt;a&amp;gt; linking to unsplash
    const item = document.createElement('a');
    setAttributes(item, {
      href: photo.links.html,
      target: '_blank'
    })

    // Create &amp;lt;img&amp;gt; for photo
    const img = document.createElement('img');
    setAttributes(img, {
      src: photo.urls.regular,
      alt: photo.alt_description,
      title: photo.alt_description
    });

    // Event Listerner, check when each is finished loading
    img.addEventListener('load', imageLoaded)

    // Put &amp;lt;img&amp;gt; inside &amp;lt;a&amp;gt;, then put both in the imageContainer;
    item.appendChild(img)
    imageContainer!.appendChild(item);
  });
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Finally, we will add the &lt;code&gt;getPhotos&lt;/code&gt; function and attach our &lt;code&gt;scroll&lt;/code&gt; event to the windows object.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Get photos from Unsplash API
const getPhotos = async () =&amp;gt; {
  try {
    const response = await fetch(API_URL);
    photosArray = await response.json()

    displayPhotos();
  } catch (error) {

  }
}

// Hook up the scroll event
window.addEventListener('scroll', () =&amp;gt; {
  if (
    window.innerHeight + window.scrollY &amp;gt;=
    document.body.offsetHeight - 1000 &amp;amp;&amp;amp;
    ready
  ) {
    ready = false;
    getPhotos();
  }
})

// On load
getPhotos();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now run the &lt;code&gt;tsc --build tsconfig.json&lt;/code&gt; to build your &lt;code&gt;.ts&lt;/code&gt; files into the required &lt;code&gt;.js&lt;/code&gt; equivalence.&lt;/p&gt;

&lt;p&gt;This was super exciting for me, I hope you enjoy it.&lt;/p&gt;

</description>
      <category>typescript</category>
      <category>api</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Typescript Beginner: Start Here</title>
      <dc:creator>Favour George</dc:creator>
      <pubDate>Tue, 13 Oct 2020 23:46:23 +0000</pubDate>
      <link>https://dev.to/phavor/typescript-beginner-start-here-4lb9</link>
      <guid>https://dev.to/phavor/typescript-beginner-start-here-4lb9</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;TypeScript is a superset of &lt;code&gt;JavaScript&lt;/code&gt; which compiles into JavaScript code. It's used to improve your code quality with OOP features and static typing. This transfers well into large-scale projects passing code between multiple team members. - &lt;code&gt;Jaime Morrison&lt;/code&gt; &lt;a href="https://whatpixel.com/is-typescript-worth-learning/"&gt;whatpixel.com&lt;/a&gt; &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;TypeScript has come to stay, the market demand is increasing and the community is amazing.&lt;/p&gt;

&lt;h2&gt;
  
  
  So you want to learn Typescript
&lt;/h2&gt;

&lt;p&gt;Learning typescript is a good decision, if you are coming from the Javascript ecosystem, OOP, FP, Typed language or nowhere; you'd find Typescript really interesting. &lt;/p&gt;

&lt;p&gt;In this post, I'll share some of the places where you can find educating content to help you learn faster.&lt;/p&gt;

&lt;h3&gt;
  
  
  Basics
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://www.typescriptlang.org/docs/"&gt;Typescript Docs&lt;/a&gt; - all of the basic things you need and beyond. This is the one-stop place you'd need throughout your journey. &lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.typescriptlang.org/docs/handbook/intro.html"&gt;The Typescript handbook&lt;/a&gt; - The handbook provides you with a strong understanding of concepts and topics in Typescript&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.freecodecamp.org/news/learn-typescript-in-5-minutes-13eda868daeb/"&gt;FreeCodeCamp's Typescript in 5 mins&lt;/a&gt; - Samples a brief overview and introductions into data-types and classes. &lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.valentinog.com/blog/typescript/"&gt;Your Friendly Guide&lt;/a&gt; - An elaborate introduction into the world of Typescript. &lt;a href="https://www.valentinog.com/#contact-me"&gt;Valentino Gagliardi&lt;/a&gt; takes a bit of a deep dive into the primary concepts around Typescript.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.educative.io/blog/typescript-tutorial"&gt;Amanda's Step By Step Guide to Learn Typescript&lt;/a&gt; - Amanda Fawcett starts with a comparison approach, comparing Javascript with Typescript and shows a step-by-step directive in picking up Typescript faster.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://levelup.gitconnected.com/typescript-for-beginners-97b568d3e110"&gt;Typescript for Beginners by RayRay&lt;/a&gt; - If you want to fast-forward into the nicer things with simplicity and clarity, read this. Enums, functions, interfaces and many more were succinctly presented.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Videos
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.pluralsight.com/courses/typescript"&gt;Typescript Fundamentals&lt;/a&gt; - John Papa breaks it all down, start here for a deep understanding of the Typescript fundamentals.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.udemy.com/course/understanding-typescript/"&gt;Understanding Typescript - 2020 Edition&lt;/a&gt; - This course by Maximilian Schwarzmüller will get you grounded.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;This Course takes you from the very Basics and its most important Feature (Types!) to the point where you're able to use TypeScript in any of your Projects. ReactJS Projects included! - &lt;code&gt;Maximilian Schwarzmüller&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.udemy.com/course/complete-typescript-2-course/"&gt;Typescript Masterclass&lt;/a&gt; - Created by the &lt;code&gt;Angular University&lt;/code&gt; is aimed at giving you all the tools you need to create your own Typescript projects from start to finish - like a Pro.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.udemy.com/course/typescript-the-complete-developers-guide/"&gt;Typescript: The Complete Developer Guide [2020]&lt;/a&gt; - Stephen Grider is all about the mastery, you'd find complex topics simplified and accessible. What's more, you have many projects to build and solidify your learning.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;Composition vs Inheritance? You'll understand it.  Build your own web framework? You'll do it.  Typescript with React/Redux?  It's here! - &lt;code&gt;Stephen Grider&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://ultimatecourses.com/courses/typescript"&gt;Ultimate Courses: Master Typescript&lt;/a&gt; - This awesome course by Todd Motto will give you new and exciting approaches to mastering Typescript.&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;This course is currently selling at a discount. &lt;a href="https://ultimatecourses.com/learn/typescript-masterclass"&gt;Grab it now&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

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

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=2pZmKW9-I_k&amp;amp;list=PL4cUxeGkcC9gUgr39Q_yD6v-bSyMwKPUI"&gt;The NetNinja on Typescript&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=ahCwqrYpIuM"&gt;Fireship with Typescript the Basics&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=BwuLxPH8IDs"&gt;Maximilian on Learn Typescript from scratch&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=rAy_3SIqT-E&amp;amp;t=4s"&gt;Typescript Crash Course with Traversy&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=XShQO3BvOyM"&gt;Introduction to Typescript by Codingtech&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Books
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.amazon.com/Programming-TypeScript-Making-JavaScript-Applications/dp/1492037656"&gt;Typescript: Making your Javascript Application Scale&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://books.goalkicker.com/TypeScriptBook2/"&gt;Goalkicker - Typescript Book 2&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://basarat.gitbook.io/typescript/"&gt;Typescript Deep Dive&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.apress.com/gp/book/9781484249789"&gt;Essential Typescript - Beginner to Pro&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.amazon.com/Effective-TypeScript-Specific-Ways-Improve/dp/1492053740"&gt;Effective Typescript&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Blogs
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://basarat.com/TypeScriptDeepDive/#/"&gt;Basarat&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://devblogs.microsoft.com/typescript/"&gt;Devblogs&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://ultimatecourses.com/blog/category/typescript/"&gt;Bultimate Courses - Todd Motto&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://blog.logrocket.com/tag/typescript/"&gt;Logrocket&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Communities
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/TypeStrong/"&gt;TypeStrong&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://discord.gg/RtN7EW"&gt;Typescript on Discord&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.typescriptlang.org/community"&gt;Official Typescript Community page&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://stackoverflow.com/questions/tagged/typescript"&gt;Stackoverflow&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://spectrum.chat/typescript?tab=posts"&gt;Spectrum&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://hashnode.com/n/typescript"&gt;Hashnode&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/microsoft/TypeScript/issues/new/choose"&gt;GitHub&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.reddit.com/r/typescript/comments/dlkkc7/typescript_community_page_updated/"&gt;Reddit&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/t/typescript"&gt;Dev.to&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Why do you use Typescript?
&lt;/h3&gt;

&lt;p&gt;Typescript is powerful, sometimes is looks dirty, the tooling and setup may seem painful initially, but the challenges it addresses make it worth the effort. So why do you use Typescript in your code?&lt;/p&gt;

&lt;p&gt;I'd really love to know... comment in the section below.&lt;/p&gt;

</description>
      <category>typescript</category>
      <category>codenewbie</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Build a Quote Generator with TypeScript</title>
      <dc:creator>Favour George</dc:creator>
      <pubDate>Fri, 09 Oct 2020 00:33:05 +0000</pubDate>
      <link>https://dev.to/phavor/build-a-quote-generator-with-typescript-3fdd</link>
      <guid>https://dev.to/phavor/build-a-quote-generator-with-typescript-3fdd</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;This post was originally published here &lt;a href="https://kodeinstincts.hashnode.dev/build-a-quote-generator-with-typescript-1" rel="noopener noreferrer"&gt;kodeinstincts.hashnode.dev&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Typescript is a beautiful language, it gives us a lot of confidence as developers, there are loads of awesome content that share Typescript's awesomeness, but today, we are going to take a different route. You want to build little projects with Typescript so you can solidify your knowledge, and that is why we are here right now.&lt;/p&gt;

&lt;h2&gt;
  
  
  Project Details
&lt;/h2&gt;

&lt;p&gt;Our quote generator is no different from the ones you've probably built with Javascript or other tutorials have covered, our job here today is to replicate our Javascript code in Typescript. &lt;/p&gt;

&lt;p&gt;So then, our app will talk to an API to fetch the quote, and then we can render the quote on our beautiful screen.&lt;/p&gt;

&lt;p&gt;This is the first on the &lt;code&gt;#JStoTSconversion&lt;/code&gt; series I'd be covering here on my blog. So let's get started with what you need to have fun here.&lt;/p&gt;

&lt;h2&gt;
  
  
  Requirements
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;HTML5&lt;/li&gt;
&lt;li&gt;CSS3&lt;/li&gt;
&lt;li&gt;Javascript&lt;/li&gt;
&lt;li&gt;Typescripts basics&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you have basic knowledge on these then you are good to go. Our next milestone is to get our project setup out of the way.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Install &lt;code&gt;typescript&lt;/code&gt; globally with &lt;code&gt;npm i -g typescript&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Structure and Initialization
&lt;/h2&gt;

&lt;p&gt;Open your terminal, create a directory in your favourite location and &lt;code&gt;cd&lt;/code&gt; into it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mkdir ts_quote_generator &amp;amp;&amp;amp; cd ts_quote_generator
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next, add the &lt;code&gt;tsconfig.json&lt;/code&gt; file in the root.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;touch tsconfig.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Fill the new &lt;code&gt;tsconfig.json&lt;/code&gt; configuration file with the code snippet below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"compilerOptions"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"sourceMap"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"target"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"es5"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"lib"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="s2"&gt;"dom"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="s2"&gt;"dom.iterable"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="s2"&gt;"ES2015"&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"module"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"CommonJS"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"outDir"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"dist/"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"strict"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We'll add a styles directory with a &lt;code&gt;styles.css&lt;/code&gt; file in it and an &lt;code&gt;index.html&lt;/code&gt; in the root. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;styles

&lt;ul&gt;
&lt;li&gt;styles.css&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;index.html&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;You can get the HTML file content from this &lt;a href="https://gist.github.com/phavor/bd89fcdf3035dc33974bab80b6bd05b2" rel="noopener noreferrer"&gt;gist&lt;/a&gt; and the stylesheet from &lt;a href="https://gist.github.com/phavor/8d149402b754e9692cd0a01f82eeb8d4" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Now let's get down to business.
&lt;/h4&gt;

&lt;p&gt;Create an &lt;code&gt;app.ts&lt;/code&gt; file in the root of the project, for testing purposes, add this line of code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;console.log("app is connected");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now open the terminal and run your first &lt;code&gt;tsc&lt;/code&gt; build command.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;tsc&lt;/code&gt; is short for &lt;code&gt;typescript compiler&lt;/code&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Run this command: &lt;code&gt;tsc --build tsconfig.json&lt;/code&gt;. You can also run the &lt;code&gt;tsc&lt;/code&gt; command without the arguments, like so: &lt;code&gt;tsc&lt;/code&gt;. This should generate a new &lt;code&gt;dist/&lt;/code&gt; directory with two files.&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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1602158243869%2FoX7L91_E3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1602158243869%2FoX7L91_E3.png" alt="directory-structure.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Run the app and visit the browser console, we should see our message logging there.&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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1602158597911%2Fc5VrOLx1Y.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1602158597911%2Fc5VrOLx1Y.png" alt="browser-console.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With our typescript compilation working, we will shift attention to fleshing out the app logic.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// app.ts&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;quoteContainer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;quote-container&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;loader&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;loader&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;quoteText&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;quote&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;authorText&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;author&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;twitterBtn&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;twitter&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;newQuoteBtn&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;new-quote&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;First, we register our DOM elements into our typescript file and hold them in memory. When making a request to the API for data, we need to show our loading state, we will write two helper functions for that &lt;code&gt;(showContentLoader)&lt;/code&gt; and &lt;code&gt;(hideContentLoader)&lt;/code&gt;;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// app.ts&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;showContentLoader&lt;/span&gt; &lt;span class="o"&gt;=&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;loader&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;quoteContainer&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;loader&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;hidden&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="nx"&gt;quoteContainer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;hidden&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="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;hideContentLoader&lt;/span&gt; &lt;span class="o"&gt;=&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;loader&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;quoteContainer&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;loader&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;hidden&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;quoteContainer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;hidden&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="nx"&gt;loader&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;hidden&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="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;In both functions, you'd notice the line &lt;code&gt;if (loader &amp;amp;&amp;amp; quoteContainer) {&lt;/code&gt;. This is because in our &lt;code&gt;tsconfig.json&lt;/code&gt; file we have specified the rule &lt;code&gt;"strict": true&lt;/code&gt;, so typescript will fail to build if we don't guard against &lt;code&gt;null&lt;/code&gt; values among other things.&lt;/p&gt;

&lt;h4&gt;
  
  
  But how did we come about the &lt;code&gt;null&lt;/code&gt; value?
&lt;/h4&gt;

&lt;p&gt;When we try to get the &lt;code&gt;HTMLElement&lt;/code&gt; from the &lt;code&gt;DOM&lt;/code&gt; via &lt;code&gt;getElementById()&lt;/code&gt; or any other API, there are 2 possible scenarios;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The element exists, and returns the corresponding data, or&lt;/li&gt;
&lt;li&gt;The element is unavailable at the moment and therefore will return &lt;code&gt;null&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When we try to read the value &lt;code&gt;loader.hidden&lt;/code&gt;, we could, in fact, be doing &lt;code&gt;null.hidden&lt;/code&gt;, this would crash our app because the &lt;code&gt;getElementById()&lt;/code&gt; method returns a union of &lt;code&gt;HTMLElement&lt;/code&gt; or &lt;code&gt;null&lt;/code&gt;. &lt;a href="https://jameshenry.blog/typescript-null-and-undefined-types/" rel="noopener noreferrer"&gt;James Henry&lt;/a&gt; talks more about this behaviour in his blog.&lt;/p&gt;

&lt;h4&gt;
  
  
  What have we gained?
&lt;/h4&gt;

&lt;p&gt;Typescript enforces these checks to help us write quality and less buggy code. By checking for the availability of these elements, we save our app from crashing. Cool right? We will continue with this method throughout the code.&lt;/p&gt;

&lt;h3&gt;
  
  
  The getQuote Function
&lt;/h3&gt;

&lt;p&gt;The &lt;code&gt;getQuote()&lt;/code&gt; is responsible for fetching our quotes from the API, we are expecting a response from that request, and hence, we will utilize Typescript's &lt;code&gt;interface&lt;/code&gt; to check for our data shape. Let's get the code;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kr"&gt;interface&lt;/span&gt; &lt;span class="nx"&gt;QuoteData&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;quoteAuthor&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;quoteText&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;quoteLink&lt;/span&gt;&lt;span class="p"&gt;?:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;senderLink&lt;/span&gt;&lt;span class="p"&gt;?:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;senderName&lt;/span&gt;&lt;span class="p"&gt;?:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// Get quote from API&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;getQuote&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;async &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="nf"&gt;showContentLoader&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;proxyUrl&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;https://cors-anywhere.herokuapp.com/&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;apiUrl&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;`https://api.forismatic.com/api/1.0/?method=getQuote&amp;amp;lang=en&amp;amp;format=json`&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;proxyUrl&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;apiUrl&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="na"&gt;data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;QuoteData&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&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;authorText&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;quoteText&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="c1"&gt;// default to annoynmous if there is no author&lt;/span&gt;
      &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;quoteAuthor&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;authorText&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;innerText&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Anoynmous&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
        &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;authorText&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;innerText&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;quoteAuthor&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

      &lt;span class="c1"&gt;// Dynamically change text size&lt;/span&gt;
      &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;quoteText&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;120&lt;/span&gt;
        &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="nx"&gt;quoteText&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;classList&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;long-quote&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;quoteText&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;classList&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;remove&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;long-quote&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

      &lt;span class="nx"&gt;quoteText&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;innerText&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;quoteText&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

      &lt;span class="c1"&gt;// show quote&lt;/span&gt;
      &lt;span class="nf"&gt;hideContentLoader&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;getQuote&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 ensure that the response coming from the API matches our &lt;code&gt;interface&lt;/code&gt; shape with this line &lt;code&gt;const data: QuoteData = await response.json();&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Tweet Function
&lt;/h3&gt;

&lt;p&gt;Hook up the tweet function and the &lt;code&gt;getQuote&lt;/code&gt; function like so:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Tweet quote&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;tweetQuote&lt;/span&gt; &lt;span class="o"&gt;=&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;quoteText&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;authorText&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;quote&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;quoteText&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;innerText&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;author&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;authorText&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;innerText&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;twitterUrl&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;`https://twitter.com/intent/tweet?text=&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;quote&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;author&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="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;twitterUrl&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;_blank&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;span class="c1"&gt;// Hook up the new tweet event&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;newQuoteBtn&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;twitterBtn&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;newQuoteBtn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addEventListener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;click&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;getQuote&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nx"&gt;twitterBtn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addEventListener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;click&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;tweetQuote&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// OnLoad&lt;/span&gt;
&lt;span class="nf"&gt;getQuote&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's all, we have added typescript to our little quote generator app. Your whole &lt;code&gt;app.ts&lt;/code&gt; should look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;quoteContainer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;quote-container&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;loader&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;loader&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;quoteText&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;quote&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;authorText&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;author&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;twitterBtn&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;twitter&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;newQuoteBtn&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;new-quote&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="kr"&gt;interface&lt;/span&gt; &lt;span class="nx"&gt;QuoteData&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;quoteAuthor&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;quoteText&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;quoteLink&lt;/span&gt;&lt;span class="p"&gt;?:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;senderLink&lt;/span&gt;&lt;span class="p"&gt;?:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;senderName&lt;/span&gt;&lt;span class="p"&gt;?:&lt;/span&gt; &lt;span class="kr"&gt;string&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;showContentLoader&lt;/span&gt; &lt;span class="o"&gt;=&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;loader&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;quoteContainer&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;loader&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;hidden&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="nx"&gt;quoteContainer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;hidden&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="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;hideContentLoader&lt;/span&gt; &lt;span class="o"&gt;=&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;loader&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;quoteContainer&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;loader&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;hidden&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;quoteContainer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;hidden&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="nx"&gt;loader&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;hidden&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="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// Get quote from API&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;getQuote&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;async &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="nf"&gt;showContentLoader&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;proxyUrl&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;https://cors-anywhere.herokuapp.com/&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;apiUrl&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;`https://api.forismatic.com/api/1.0/?method=getQuote&amp;amp;lang=en&amp;amp;format=json`&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;proxyUrl&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;apiUrl&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="na"&gt;data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;QuoteData&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&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;authorText&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;quoteText&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="c1"&gt;// default to annoynmous if there is no author&lt;/span&gt;
      &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;quoteAuthor&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;authorText&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;innerText&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Anoynmous&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
        &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;authorText&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;innerText&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;quoteAuthor&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

      &lt;span class="c1"&gt;// Dynamically change text size&lt;/span&gt;
      &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;quoteText&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;120&lt;/span&gt;
        &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="nx"&gt;quoteText&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;classList&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;long-quote&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;quoteText&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;classList&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;remove&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;long-quote&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

      &lt;span class="nx"&gt;quoteText&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;innerText&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;quoteText&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

      &lt;span class="c1"&gt;// show quote&lt;/span&gt;
      &lt;span class="nf"&gt;hideContentLoader&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;getQuote&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="c1"&gt;// Tweet quote&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;tweetQuote&lt;/span&gt; &lt;span class="o"&gt;=&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;quoteText&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;authorText&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;quote&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;quoteText&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;innerText&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;author&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;authorText&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;innerText&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;twitterUrl&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;`https://twitter.com/intent/tweet?text=&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;quote&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;author&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="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;twitterUrl&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;_blank&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;span class="c1"&gt;// Hook up the new tweet event&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;newQuoteBtn&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;twitterBtn&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;newQuoteBtn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addEventListener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;click&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;getQuote&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nx"&gt;twitterBtn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addEventListener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;click&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;tweetQuote&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// OnLoad&lt;/span&gt;
&lt;span class="nf"&gt;getQuote&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Final Step
&lt;/h2&gt;

&lt;p&gt;To get your new typescript file ready for the browser, open the terminal and run the build command again.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;tsc --build tsconfig.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Todo
&lt;/h2&gt;

&lt;p&gt;You can optimize the &lt;code&gt;getQuote&lt;/code&gt; function, it's recursive nature could mean a perpetual loading or crashing of our app if anything happens with the API providers. Set up a mechanism to guard against that. See the &lt;a href="https://github.com/crea8lab/quotifr" rel="noopener noreferrer"&gt;GitHub code here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;See you in the next &lt;code&gt;#JStoTSConversion&lt;/code&gt;.&lt;/p&gt;

</description>
      <category>typescript</category>
      <category>javascript</category>
      <category>dom</category>
      <category>api</category>
    </item>
    <item>
      <title>The First Things About Your Teams' Agility</title>
      <dc:creator>Favour George</dc:creator>
      <pubDate>Mon, 05 Oct 2020 11:31:28 +0000</pubDate>
      <link>https://dev.to/phavor/the-first-things-about-your-teams-agility-35m1</link>
      <guid>https://dev.to/phavor/the-first-things-about-your-teams-agility-35m1</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;This was originally published here &lt;a href="https://kodeinstincts.hashnode.dev/the-first-things-about-your-teams-agility"&gt;kodeinstincts.hashnode.dev&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Agile is a thinking methodology, a system of operation, a culture that governs systems and processes within a team.&lt;/p&gt;

&lt;p&gt;Agile methodologies stem from the "Agile Manifesto". Agile is not a framework, software or tool, it's a concept, a way of thinking, a culture of product/service delivery.&lt;/p&gt;

&lt;p&gt;Agile is about values; these values are enshrined in the &lt;a href="https://www.atlassian.com/agile/manifesto"&gt;Agile Manifesto&lt;/a&gt; which places the customer experience over the product development cycle. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The manifesto essentially values people above interactions and processes, working software/product above documentation, customer collaboration and satisfaction above contract negotiation, responding to changes above following product development plans. &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Agile is discipline agnostic, this means; it works anywhere, from engineering to marketing, law enforcement, media, software development, etc. The need for an agile culture is rather obvious as customers are daily becoming more and more aware of what products and services can offer them, they have inadvertently become more selective, impatient and unforgiving. &lt;/p&gt;

&lt;p&gt;Over the years some frameworks have been developed around the Agile concept, these frameworks help solidify the agile manifesto in principles and actions. The "Scrum" and "Kanban" are some of the most notable of such frameworks. &lt;br&gt;
As a team you have to choose what works best for your team, it could be one or a hybrid of the frameworks with a touch of your teams' unique flavour. The goal is to keep the fidelity of the Agile Manifesto while giving it the interpretation that best suits your team.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Agile offers you
&lt;/h2&gt;

&lt;p&gt;As opposed to the traditional product development and delivery methods, where a team of product developers, designers and owners lock-in with product spec and build it from scratch until they feel their customers will love it, then they ship. Until it's shipped they have no real feedback, no real interactions with the market forces, no meaningful data for validation of their product, processes and systems.  &lt;/p&gt;

&lt;p&gt;It becomes harder for such a team to respond to changes, they may have to pull out a large chunk of the codebase to respond to a minor/major change, it takes them a long time to fully respond to these dynamics because they aren't prepared for it. They just aren't Agile.&lt;/p&gt;

&lt;p&gt;An Agile team is happy with the Minimum Viable Product (MVP), you have surely heard of the term; an MVP represents the smallest working product or features your users can interact with. The MVP is a model to curry feedback to the team. Features are added incrementally as customers favour or dislike the current one. What you find is that these MVPs may not be elegant looking, but they are functional, they are Agile. &lt;/p&gt;

&lt;p&gt;An MVP could be termed as the teams' "increment", their definition of done, a milestone, or a shippable Epic. These MVPs are products of sprints engaged by the team, a sprint typically should span a 2-week period. Sprints have backlogs which are definitions of ToDos curated from the project backlog. These backlogs are filtered and altered according to the feedback received from the last shipment. You immediately see how Agile is immersive, involving the customer, designers, developers and product owners.&lt;/p&gt;

&lt;p&gt;An Agile team will get to the market faster, get realistic feedback and reiterate on their product, services and systems to meet their customers evolving needs and taste, as well as save production cost. They handle changes more efficiently, implement new features with more confidence and have a more committed team and happy customer base. They are Agile, responsive and dynamic. They learn by failing, you could say failure is their best friend. They constantly reiterate over their failing processes until they have the system that works.&lt;/p&gt;

&lt;p&gt;Is your team Agile yet? What Agile methodologies are you implementing? Are you an Agile practitioner? &lt;/p&gt;

&lt;p&gt;Keep an eye here as we increase your agility.&lt;/p&gt;

</description>
      <category>agile</category>
      <category>software</category>
      <category>kanban</category>
      <category>scrum</category>
    </item>
    <item>
      <title>Building A CRON-MAN In NodeJs</title>
      <dc:creator>Favour George</dc:creator>
      <pubDate>Sat, 21 Sep 2019 15:42:47 +0000</pubDate>
      <link>https://dev.to/phavor/building-a-cron-man-in-nodejs-27ic</link>
      <guid>https://dev.to/phavor/building-a-cron-man-in-nodejs-27ic</guid>
      <description>&lt;p&gt;In this article we are going to learn how to setup a NodeJs cron-job, our cron will lookup our database collection and delete redundant users. We are going to see a few NodeJs APIs that will help us achieve our desired goal.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is a CRON JOB?
&lt;/h2&gt;

&lt;p&gt;A cronjob is a program that runs regularly at a specified time and carries out any specified task. You may think of it as a bot. You could want to send out newsletters to all who signed up on your platform today, you could want to check another service which your application uses for updates and then correctly update your own service. You could do just about anything with a cronjob. &lt;/p&gt;

&lt;h2&gt;
  
  
  Okay, I hear you, why do I need a CRONJOB?
&lt;/h2&gt;

&lt;p&gt;You see, while working with a database, you may notice that users of your application often upload or save files which they do not need into your database or cloud storage bucket. Your cronjob would occasionally check your storage system, find these redundant files and implement your desired instructions. You are not limited to the database anyway, you can implement this just about anywhere, ideally, the storage system is a popular use case.&lt;/p&gt;

&lt;p&gt;The cron-man or manager will handle all our cronjobs. This means all our cronjobs will be managed from the same file.&lt;/p&gt;

&lt;h2&gt;
  
  
  Ready? Now let's get started
&lt;/h2&gt;

&lt;p&gt;I will assume you already have a functional &lt;strong&gt;View&lt;/strong&gt; and &lt;strong&gt;Model&lt;/strong&gt; already, so we can get to the cron manager immediately.&lt;/p&gt;

&lt;p&gt;We will structure our cronjob runner into 3 parts:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The Scheduler&lt;/li&gt;
&lt;li&gt;The Action&lt;/li&gt;
&lt;li&gt;The cron-man&lt;/li&gt;
&lt;/ul&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%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fbdq5g1doqm04mtj5jaab.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fbdq5g1doqm04mtj5jaab.png" alt="cron-job work flow The Scheduler"&gt;&lt;/a&gt;&lt;br&gt;The Scheduler
&lt;/p&gt;

&lt;p&gt;The scheduler will take in 2 parameters, the time interval in milliseconds and the action to run.&lt;/p&gt;
&lt;h3&gt;
  
  
  The Action
&lt;/h3&gt;

&lt;p&gt;This is a function which will be called by our &lt;code&gt;scheduler&lt;/code&gt;, this function bears the logic of what needs to be done every time our scheduler calls it. It is important to make your actions pure. Using pure functions will help check against memory leaks and side-effects. &lt;/p&gt;
&lt;h3&gt;
  
  
  The Cron-Man
&lt;/h3&gt;

&lt;p&gt;The cron manager will bootstrap all our schedulers and manage them for us. We simply import our scheduler function and actions here. This is important for debugging and more so it makes our cron modular.&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%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fh7mq15klhm1hs0sa7u0j.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fh7mq15klhm1hs0sa7u0j.png" alt="The cron manager"&gt;&lt;/a&gt;&lt;br&gt;The cron manager
&lt;/p&gt;

&lt;p&gt;Now that we have conceptually described our cron program, let's get into the code level. Create a cron directory in your project, it should have 2 sub folders (&lt;code&gt;cron-jobs&lt;/code&gt; &amp;amp; &lt;code&gt;scheduler&lt;/code&gt;) and the &lt;code&gt;cronMan.js&lt;/code&gt; file.&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%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fu6h0vcmp9ecqvbfgwju3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fu6h0vcmp9ecqvbfgwju3.png" alt="folder structure"&gt;&lt;/a&gt;&lt;br&gt;Your folder structure
&lt;/p&gt;

&lt;p&gt;We start by fleshing out the scheduler function. It will look like so:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Our scheduler needs two vital pieces. The &lt;code&gt;setInterval()&lt;/code&gt; timer API and the &lt;code&gt;process.nextTick()&lt;/code&gt; API from NodeJs. For more information on the timer API, see their &lt;a href="https://nodejs.org/docs/latest-v10.x/api/timers.html" rel="noopener noreferrer"&gt;documentation&lt;/a&gt;. The &lt;code&gt;setInterval()&lt;/code&gt; takes the time and the action to call once the time provided has elapsed. &lt;/p&gt;

&lt;p&gt;The &lt;code&gt;process.nextTick()&lt;/code&gt; will ensure that our scheduler function is called once the current job in the NodeJs event loop is completed. It gets called before any other I/O event, or timers are loaded into the event loop. This is a good way for us to hook into the life-cycle of our program and inject our cron job. &lt;/p&gt;

&lt;p&gt;There is a beautiful article written by &lt;a href="https://twitter.com/towersofzeyron" rel="noopener noreferrer"&gt;Tendai Mutunhire&lt;/a&gt; on this. You should check it out: &lt;a href="https://stackabuse.com/how-to-use-timers-and-events-in-node-js/" rel="noopener noreferrer"&gt;Events and Timers in Node.js&lt;/a&gt;. You can also see the official documentation on &lt;a href="https://nodejs.org/docs/latest-v10.x/api/process.html#process_process_nexttick_callback_args" rel="noopener noreferrer"&gt;process.nextTick(callback[,…args])&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's continue building, now we will focus on the &lt;code&gt;actions&lt;/code&gt;. You will notice how we have named our directory &lt;code&gt;cron-jobs&lt;/code&gt;, this means we can have more than one job and house them together inside of the &lt;code&gt;cron-jobs&lt;/code&gt; directory. &lt;/p&gt;

&lt;p&gt;For this example, we will setup a &lt;code&gt;deleteInactives&lt;/code&gt; cronjob. This will lookup our database and delete all currently inactive users. &lt;br&gt;
In a real-world application, you should not delete the users, but the redundant files they have, like pictures, videos, pdfs, and the likes which have not been saved by the user but uploaded to your database.&lt;/p&gt;

&lt;p&gt;In our example app, say we give all users 24 hours to activate their accounts, at the expiration of this time, we will delete all inactive accounts. Great, let's write the code now.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Our &lt;code&gt;deleteInactive&lt;/code&gt; users function above will remove any user whose &lt;code&gt;isActive&lt;/code&gt; property is &lt;code&gt;false&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Let's now set up the cron manager file, open the &lt;code&gt;cronMan.js&lt;/code&gt; file and write code away…&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;All we have to do now is to inject the cronMan.js file into our app. Inside our index.js, we will require the &lt;code&gt;cronMan&lt;/code&gt; file at line 1 like so:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;require("./cron-man/cronMan");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Awesome, now when check our console we should see new messages logging the number of users deleted.&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%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F0n47tp8y0o15ixd0wsc4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F0n47tp8y0o15ixd0wsc4.png" alt="our results after the cron jobs have been called repeatedly"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Currently, our scheduled job runs every &lt;code&gt;10000&lt;/code&gt; milliseconds, you should set your timer according to the needs of your application.&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%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F2wlhjq7o4rlcij6th288.gif" 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%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F2wlhjq7o4rlcij6th288.gif" alt="you rock"&gt;&lt;/a&gt; &lt;br&gt;you rock
&lt;/p&gt;

&lt;p&gt;There you have it. You have successfully set-up your first CRON-JOB. That was easy right? Now go and save the world your cron-man 🚀🚀🚀&lt;/p&gt;

</description>
      <category>node</category>
      <category>cron</category>
      <category>bot</category>
      <category>database</category>
    </item>
    <item>
      <title>Tracking Result </title>
      <dc:creator>Favour George</dc:creator>
      <pubDate>Thu, 21 Jun 2018 23:54:07 +0000</pubDate>
      <link>https://dev.to/phavor/tracking-result--4kg6</link>
      <guid>https://dev.to/phavor/tracking-result--4kg6</guid>
      <description>&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%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fnuhdjeb57owqzjnd1go1.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%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fnuhdjeb57owqzjnd1go1.jpg" alt="Tracking Results successfully"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Sometimes it’s hard to figure out what you have achieved, keeping track of the past comes with a price, one that most people prefer not to pay. The importance of keeping these records abundantly reveal that sticking with this seemingly painful habit is rewarding. Most multi-national companies implement this on daily basis, even if you had a month old start-up you could take advantage of this and steer your business into greatness. You may or may not be a record keeper, statistician or anything of the sort, but learning these principles would help you decisively place your work, business or personality on the platform that matters.&lt;/p&gt;

&lt;p&gt;These steps would help you stay on top of this habit if you read on…&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;HAVE A PLAN&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;This is arguably the most talked about step in the history of articles, while this may be true, the essence of this step cannot be over-emphasized. Having plans help you to stay on track, articulate and take decisions faster. Plans help you visualize the road map leading to your destination.&lt;/p&gt;

&lt;p&gt;If there were no plans, it becomes difficult to say where on the progress line you were at the moment. Modeling your actions on paper makes your transition to the Result faster.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;WIN TODAY&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Next up after you have setup a proper plan, you have to start off the process with the Goals of winning today!&lt;/p&gt;

&lt;p&gt;What that means? Set plans that you will have to achieve TODAY. Whether they are simple or not! You have to start out conquering the activities of Today. Say you have a Press Conference talk to hold, a meeting at the office with the Regional Managers, a Date with a family member late in the evening and perhaps a quick manifest at the gym, that is sure some scheduling to do… but your day won’t be entirely successful if half of the things to-do were not done.&lt;/p&gt;

&lt;p&gt;So you take all the activities and stack them by precedence and priority, this allows you to know what is important at the moment and focus your energy and attention to completing it.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;If today is lost, tomorrow is half spent fixing today. @tz_fayvor&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;So keep a clean record of these little daily activities that make up the big picture and finish them on time. That way you are efficiently producing the needed Result.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;AUDIT TODAY&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;At the end of everyday, you should take out sometime to briefly check through your list / plan and discover which ones you did complete, which ones were half done and why? Maybe some circumstances beyond your control came up and distorted the flow of things… you will have to note this down and look out for ways to handle such logistics next-time they show up so they don’t ultimately stall your progress.&lt;/p&gt;

&lt;p&gt;You also do need to note what was done well, what was done perfectly well and what was untouched at all. To increase productivity, you may need to constantly improve your way of doing things well… seek for ways to do them better.&lt;/p&gt;

&lt;p&gt;Keeping record about this would help you know when, how and why you are improving.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;TAKE DECISIONS ON TIME&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;To get more result, you have to take decisions on time. Decisions are the pivot points that define balance in whatever you do. When you have a habit of taking decision late, or making the wrong decisions, you will discover you almost always have the poor results rewarded.&lt;/p&gt;

&lt;p&gt;In my opinion it is best to take decisions while planing; at such moments you get a peek into each future moment. What actions would ensue based on the current decision. What reactive measure could safely handle bad occurrences or what decisions are best suited for a particular task and why those decisions matter!&lt;/p&gt;

&lt;p&gt;Taking Decisions in the middle of execution is somewhat unhealthy because there could be pressures that would lead you to taking the wrong decision. You get what am trying to say right? You just have to have it ready. You just have to be prepared and ready to tackle stuffs right? Pressuring yourself into a decision could hurt when the pressure recedes and you become more rational.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Decisions sharpen Precisions&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;To forestall this, you need to take decisions ahead of time, and be confident those decision are right for you and the Result you seek. Be sure to know why such decisions are right and then stand by your decisions. This will make people believe in you and your Results. Even if they fail at the moment be sure to be firm on your decisions.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;STAY FOCUSED AND POSITIVE&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Getting the required Result most times can be a rather unbearable process. But with patience, focus and hard-work virtually anything pays off. When the ladder becomes too steep to ascend, hold on and stay positive. A lot of people are in rots and are clanged up with a myriad of barriers, while giving up may seem good an option, breaking to the realms of success will take a lot of determination, courage and focus.&lt;/p&gt;

&lt;p&gt;Most times you could need support from environment, people and friends around you. The support you seek should be one that drives you to fulfilling your set goals and not the other way round.&lt;/p&gt;

&lt;p&gt;Its good you have come this far. I am excited you stayed with me through it. I am more than excited to hear your success story and help spread your Result approach to all that care to listen… we can get talking @tz_fayvor on twitter, @ignyte4 on twitter and also facebook.&lt;/p&gt;

</description>
      <category>selfimprovement</category>
      <category>entrepreneurs</category>
      <category>development</category>
      <category>career</category>
    </item>
  </channel>
</rss>
