<?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: Joseph Hughes</title>
    <description>The latest articles on DEV Community by Joseph Hughes (@joehughesdev).</description>
    <link>https://dev.to/joehughesdev</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%2F170208%2Fdd28ca4c-69e7-481a-a25f-adb91710c704.jpg</url>
      <title>DEV Community: Joseph Hughes</title>
      <link>https://dev.to/joehughesdev</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/joehughesdev"/>
    <language>en</language>
    <item>
      <title>Async and Await Quick Guide</title>
      <dc:creator>Joseph Hughes</dc:creator>
      <pubDate>Wed, 26 Aug 2020 12:21:07 +0000</pubDate>
      <link>https://dev.to/joehughesdev/async-and-await-quick-guide-c3g</link>
      <guid>https://dev.to/joehughesdev/async-and-await-quick-guide-c3g</guid>
      <description>&lt;p&gt;Async and Await were introduced as ways to reduce headaches around nested callbacks. Async/Await is another way for you to wait for a result to return before continuing. At a basic level they are a keyword put before a function and then another keyword put before a promise that forces JavaScript to wait for that promise to return it's results.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;async function functionName(){
  let value = await functionReturningPromise();
}

// arrow syntax
let functionName = async () =&amp;gt; {
   let value = await functionReturningPromise();
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Currently, awaits are limited in being used from inside of an async function, however there is an update coming to allow for awaits to be used at the top level of your code. This will remove the need for await to be inside of an async function.&lt;/p&gt;

&lt;p&gt;Async/Await can also be used inside of a class by putting async on the method similar to how you would a function.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class ClassName{
  async methodName(){
    let value = await functionReturningPromise();
  }
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;On common thing people forget to do with the new syntax is to catch your errors. This is simple, simply wrap the await inside of a try..catch&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;async function functionName(){
  try{
    let value = await functionReturningPromise();
  } catch(err) {
    // handle err here
    console.log('error: ' , err);
  }
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Also you can have multiple awaits inside the same function. The 2nd await will not run until the 1st await finishes.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;async function functionName(){
  try{
    let value = await functionReturningPromise();
    let finalResult = await functionReturningPromiseTwo(value);
  } catch(err) {
    // handle err here
    console.log('error: ' , err);
  }
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Async/Await is nothing to be afraid of, in fact it will simplify your code by reducing nested callbacks.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>async</category>
      <category>await</category>
    </item>
    <item>
      <title>CSS Media Queries you don't know</title>
      <dc:creator>Joseph Hughes</dc:creator>
      <pubDate>Sat, 25 Jul 2020 18:38:28 +0000</pubDate>
      <link>https://dev.to/joehughesdev/https-www-joehughes-dev-css-media-queries-you-don-t-know-4lc2</link>
      <guid>https://dev.to/joehughesdev/https-www-joehughes-dev-css-media-queries-you-don-t-know-4lc2</guid>
      <description>&lt;p&gt;CSS media queries were introduced as part of CSS3. They allow for you to change your CSS based upon the device or device's characteristics. You are likely already using these to adjust the look of your page based on the width of your screen. However, they have multiple other functionalities that are often overlooked.&lt;/p&gt;

&lt;p&gt;A typical media query looks like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@media screen and (min-width: 1200px){
  ...
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;However, you can do much more than checking if the css will be displayed on a screen of 1200px or more.&lt;/p&gt;

&lt;p&gt;You can also see if the page is being printed&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@media print{
  // removing background-color and images for print friendlyness
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;You can also check orientation of the viewport&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@media (orientation: landscape){
  // Great for changing how your site looks on a phone
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;You can check if the device allows for you to hover&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@media hover{
  // change hover features to a click feature.
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;You can even check whether the device has an input mechanism that can hover&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@media (any-hover: hover){
  // Display hover CSS only to devices that have a device that can hover connected to it.
}

@media (any-hover: none){
  // The same as above but none
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Another great media query for phone support would be any-pointer that lets you&lt;br&gt;
tell if a device has a pointer and how fine the pointer is.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@media (any-pointer: fine){
  // Make the button small
}

@media (any-pointer: coarse){
  // Make the button larger, likely on a cell phone
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;As the web matures we've found that the web should cater to all users. Media queries are a great way to do that. Here are some additional ways you can improve your user experience.&lt;/p&gt;

&lt;p&gt;Users who are sensitive to motion can disable it on their computer.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@media(prefers-reduced-motion: reduce){
  // remove distracting animations
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;And finally, you can even see if JavaScript is enabled&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@media(scripting: none){
  // display content that would otherwise be hidden behind a JavaScript show/hide.
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;As you can see, there are lots of great media queries you probably didn't know existed. Hopefully you'll be able to use these on your next project.&lt;/p&gt;

</description>
      <category>css</category>
      <category>frontend</category>
      <category>mediaqueries</category>
      <category>css3</category>
    </item>
    <item>
      <title>How do unique results per user work on huge sites like Twitter, Reddit, etc. Especially with complex criteria.</title>
      <dc:creator>Joseph Hughes</dc:creator>
      <pubDate>Fri, 10 Apr 2020 12:11:52 +0000</pubDate>
      <link>https://dev.to/joehughesdev/how-do-unique-results-per-user-work-on-huge-sites-like-twitter-reddit-etc-especially-with-complex-criteria-11f8</link>
      <guid>https://dev.to/joehughesdev/how-do-unique-results-per-user-work-on-huge-sites-like-twitter-reddit-etc-especially-with-complex-criteria-11f8</guid>
      <description>&lt;p&gt;How do sites with millions of users that serve up unique search results weighted by the individuals interests in a quick and scalable way.&lt;/p&gt;

&lt;p&gt;For instance let’s say I have a site with 50,000,000 users, 100,000 categories, 10 different ordering criteria (new, best, controversial, etc). I want to return back the results per the persons unique criteria updating continually on the fly showing the best content from all the areas ordered by the best first.&lt;/p&gt;

&lt;p&gt;Really interested in how you’d go about doing something like this at huge scale&lt;/p&gt;

</description>
      <category>database</category>
      <category>help</category>
      <category>discuss</category>
    </item>
  </channel>
</rss>
