<?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: The Method Coder</title>
    <description>The latest articles on DEV Community by The Method Coder (@methodcoder).</description>
    <link>https://dev.to/methodcoder</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%2Forganization%2Fprofile_image%2F1602%2Ff0ba7b5e-7a1c-4936-85f8-de2d628d5e82.png</url>
      <title>DEV Community: The Method Coder</title>
      <link>https://dev.to/methodcoder</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/methodcoder"/>
    <language>en</language>
    <item>
      <title>🔥 Debugging Frontend Apps inside VS Code!</title>
      <dc:creator>hexrcs</dc:creator>
      <pubDate>Wed, 22 Jan 2020 09:19:15 +0000</pubDate>
      <link>https://dev.to/methodcoder/debugging-frontend-app-inside-vs-code-4cg0</link>
      <guid>https://dev.to/methodcoder/debugging-frontend-app-inside-vs-code-4cg0</guid>
      <description>&lt;p&gt;Did you know that we can also debug client-side, frontend code right from VS Code, using its powerful built-in debugger? 🤯&lt;/p&gt;

&lt;p&gt;In this 94-second video, we'll use the Chrome debugger extension to debug an event handler in a React app.&lt;/p&gt;

&lt;p&gt;Although the demo is in React, the same knowledge applies to any frontend apps! 🥳&lt;/p&gt;




&lt;p&gt;This video is part of my new 6-minute crash course series on YouTube 👉 &lt;a href="https://www.youtube.com/playlist?list=PLyNmzPg2z6Og_dyyeVviQxefnG06rq_FK" rel="noopener noreferrer"&gt;&lt;strong&gt;Debugging in VS Code&lt;/strong&gt; 🔥&lt;/a&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;strong&gt;Like this video?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;I'm also on Twitter: &lt;a href="https://twitter.com/hexrcs" rel="noopener noreferrer"&gt;@hexrcs&lt;/a&gt;&lt;/em&gt;&lt;br&gt;&lt;em&gt;Check out my YouTube Channel: &lt;a href="http://methodcoder.com/" rel="noopener noreferrer"&gt;The Method Coder&lt;/a&gt;&lt;/em&gt;&lt;br&gt;&lt;em&gt;You can find me at my homepage as well: &lt;a href="https://www.xiaoru.li" rel="noopener noreferrer"&gt;xiaoru.li&lt;/a&gt;&lt;/em&gt;&lt;br&gt;&lt;/p&gt;

</description>
      <category>productivity</category>
      <category>vscode</category>
      <category>tutorial</category>
      <category>webdev</category>
    </item>
    <item>
      <title>💪 React + MobX Crash Course (in 5 pics!)</title>
      <dc:creator>hexrcs</dc:creator>
      <pubDate>Tue, 03 Dec 2019 13:25:39 +0000</pubDate>
      <link>https://dev.to/methodcoder/react-mobx-crash-course-in-5-pics-2m3b</link>
      <guid>https://dev.to/methodcoder/react-mobx-crash-course-in-5-pics-2m3b</guid>
      <description>&lt;p&gt;&lt;em&gt;Originally posted on Twitter as a thread: &lt;a href="https://twitter.com/hexrcs/status/1201593792417144833" rel="noopener noreferrer"&gt;https://twitter.com/hexrcs/status/1201593792417144833&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;State management in React apps can be a hard thing to do.&lt;/p&gt;

&lt;p&gt;Are you having a hard time wrapping your head around React state management, and getting tired of writing boilerplate for Redux?&lt;/p&gt;

&lt;p&gt;Let's check out &lt;a href="https://github.com/mobxjs/mobx" rel="noopener noreferrer"&gt;MobX&lt;/a&gt; - everything becomes so simple and effortless 😃&lt;/p&gt;

&lt;p&gt;👇 Here's a 5-minute React + MobX crash course for you! 🥳&lt;/p&gt;

&lt;h2&gt;
  
  
  1 - MobX Concepts
&lt;/h2&gt;

&lt;p&gt;MobX is a "reactive" state management library.&lt;/p&gt;

&lt;p&gt;We directly mutate the state. Because we use MobX to observe and track mutations, the UI will be auto-updated, like cell updates in Excel. Network requests can also auto-send when conditions are met.&lt;/p&gt;

&lt;p&gt;Everything is automatic!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--WBGaappo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://i.imgur.com/9zqUM2a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--WBGaappo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://i.imgur.com/9zqUM2a.png" alt="MobX Concepts" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  2 - Decorator and observable
&lt;/h2&gt;

&lt;p&gt;We normally use the decorator syntax to mark fields in a class "MobX observables" - easy to use or read. This way, normal JS stuff gets "enhanced" (eg. a JS number becomes an observable that can be tracked).&lt;/p&gt;

&lt;p&gt;Grouping state logic in a "store" also makes our code more modular.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--qvZ-CzhE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://i.imgur.com/69Buoof.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--qvZ-CzhE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://i.imgur.com/69Buoof.png" alt="Decorator and observable" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Action and Computed
&lt;/h2&gt;

&lt;p&gt;In addition to &lt;code&gt;@observable&lt;/code&gt;, we also have:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;@computed&lt;/code&gt; - derived state from other observable/computed that can be used just like observables. Getter syntax is required. The derivation is automatic.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;@action&lt;/code&gt; - batched state mutations. Reactions will only be triggered by the update when the action completes.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--N7iKiL82--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://i.imgur.com/WRTYfQi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--N7iKiL82--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://i.imgur.com/WRTYfQi.png" alt="Action and Computed" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;p&gt;We can use &lt;code&gt;autorun()&lt;/code&gt; or &lt;code&gt;when()&lt;/code&gt; to watch observables and perform effects when there's update&lt;/p&gt;

&lt;p&gt;&lt;code&gt;autorun()&lt;/code&gt; takes a callback and runs it each time any observable used in it gets updated. (Remember to do the clean-up!)&lt;/p&gt;

&lt;p&gt;&lt;code&gt;when()&lt;/code&gt; only runs the callback once, when a condition is met.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--TBMUwMvB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://i.imgur.com/kGKGSjY.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--TBMUwMvB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://i.imgur.com/kGKGSjY.png" alt="Reactions" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Using MobX with React
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;mobx-react&lt;/code&gt; binding lets us use MobX with React without writing &lt;code&gt;autorun&lt;/code&gt; functions to rerender components.&lt;/p&gt;

&lt;p&gt;We use &lt;code&gt;@observer&lt;/code&gt; as a decorator to a class component, or HoC wrapping a function component. This creates an observer component that tracks observables needed during render, and auto rerenders whenever an update is observed.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--hsG4tNuY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://i.imgur.com/jTaDvPn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--hsG4tNuY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://i.imgur.com/jTaDvPn.png" alt="Using MobX with React" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;And that's it, everything you need to start using MobX effectively. Pretty effortless, isn't it? 😃&lt;/p&gt;

&lt;p&gt;If you are curious how MobX works under the hood, check out this amazing talk "&lt;a href="https://www.youtube.com/watch?v=P_WqKZxpX8g" rel="noopener noreferrer"&gt;Reinventing MobX&lt;/a&gt;" by Max Gallo.&lt;/p&gt;

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

&lt;h3&gt;
  
  
  Credits
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;Thank you so much &lt;a href="https://twitter.com/mweststrate" rel="noopener noreferrer"&gt;Michel Weststrate&lt;/a&gt; for creating this amazing library, and helping to review this crash course! 🙌&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;(Thread crash course format inspired by &lt;a href="https://twitter.com/chrisachard" rel="noopener noreferrer"&gt;Chris Achard&lt;/a&gt; 😁 Check out his excellent React/Redux, Git crash courses!)&lt;/em&gt;&lt;/p&gt;




&lt;p&gt;While you are still here, if you've got 13 more minutes and are interested in learning the new hot framework Svelte, I've also got a crash course with companion videos here 👉 &lt;a href="https://dev.to/hexrcs/svelte-crash-course-with-pics-27cc"&gt;&lt;strong&gt;Svelte Crash Course&lt;/strong&gt; 🔥&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I've also got another &lt;a href="https://dev.to/hexrcs/graphql-crash-course-in-10-pics-3b04"&gt;&lt;strong&gt;GraphQL Crash Course&lt;/strong&gt; 🔥&lt;/a&gt; 👈 Check it out!&lt;/p&gt;

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

&lt;p&gt;&lt;strong&gt;Like this post?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;I'll be posting more on Twitter: &lt;a href="https://twitter.com/hexrcs" rel="noopener noreferrer"&gt;@hexrcs&lt;/a&gt;&lt;/em&gt;&lt;br&gt;&lt;em&gt;You can also find me at my homepage: &lt;a href="https://www.xiaoru.li" rel="noopener noreferrer"&gt;xiaoru.li&lt;/a&gt;&lt;/em&gt;&lt;br&gt;&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>webdev</category>
      <category>beginners</category>
    </item>
    <item>
      <title>🔥 GraphQL Crash Course (in 10 pics!)</title>
      <dc:creator>hexrcs</dc:creator>
      <pubDate>Sun, 03 Nov 2019 10:34:24 +0000</pubDate>
      <link>https://dev.to/methodcoder/graphql-crash-course-in-10-pics-3b04</link>
      <guid>https://dev.to/methodcoder/graphql-crash-course-in-10-pics-3b04</guid>
      <description>&lt;p&gt;&lt;em&gt;Originally posted on Twitter as a thread: &lt;a href="https://twitter.com/hexrcs/status/1190332090149150720" rel="noopener noreferrer"&gt;https://twitter.com/hexrcs/status/1190332090149150720&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Always wanted to use GraphQL for your new projects, but never got time to learn how it works? 😃&lt;/p&gt;

&lt;p&gt;Let's start the week with some new GraphQL knowledge in hand! 🙌&lt;/p&gt;

&lt;p&gt;👇 Here's a 10-minute GraphQL crash course for you! 🥳&lt;/p&gt;

&lt;h2&gt;
  
  
  1 - How GraphQL works
&lt;/h2&gt;

&lt;p&gt;GraphQL is a query language for making flexible API calls.&lt;/p&gt;

&lt;p&gt;We describe what we want in a single request with nested fields, then we will receive a data payload of the exact shape.&lt;/p&gt;

&lt;p&gt;No need to make many small requests to stitch data together or over-fetch unwanted parts!&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%2Fi.imgur.com%2FZalpOf7.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%2Fi.imgur.com%2FZalpOf7.png" alt="How GraphQL works"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  2 - A GraphQL Query Exchange
&lt;/h2&gt;

&lt;p&gt;GraphQL is not a library, but a language spec.&lt;/p&gt;

&lt;p&gt;We send structured queries as POST or GET requests. The server checks if they're valid with a predefined schema, runs corresponding resolver functions to perform operations, then prepares the data to be returned to the client.&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%2Fi.imgur.com%2FcIqFAw8.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%2Fi.imgur.com%2FcIqFAw8.png" alt="A GraphQL Query Exchange"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  3 - The GraphQL Schema
&lt;/h2&gt;

&lt;p&gt;GraphQL schema defines the structure of valid queries and the return data types of them. It's the protocol the client &amp;amp; server use to communicate under.&lt;/p&gt;

&lt;p&gt;They're strongly typed, can be nested. In addition to the most common "object" types, the schema also supports unions, enums, interfaces, etc.&lt;/p&gt;

&lt;p&gt;There are 3 operation types in GraphQL - &lt;code&gt;query&lt;/code&gt;, &lt;code&gt;mutation&lt;/code&gt;, or &lt;code&gt;subscription&lt;/code&gt;. &lt;code&gt;query&lt;/code&gt; is the most commonly used operation.&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%2Fi.imgur.com%2FzyTgxJr.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%2Fi.imgur.com%2FzyTgxJr.png" alt="The GraphQL Schema"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  4 - Argument
&lt;/h2&gt;

&lt;p&gt;Some queries allow us to pass in arguments in order to eg. filter results. The schema defines all valid arguments.&lt;/p&gt;

&lt;p&gt;On the backend, we need to have corresponding resolvers to fulfill those conditioned queries.&lt;/p&gt;

&lt;p&gt;NOTE: GraphQL has no builtin comparison operators or functions like &lt;code&gt;&amp;gt;&lt;/code&gt; or &lt;code&gt;TOP&lt;/code&gt;, &lt;code&gt;LIMIT&lt;/code&gt; in SQL! Those additional features &lt;strong&gt;must&lt;/strong&gt; be implemented in the resolvers. Most GraphQL frameworks however already ship with those utility resolvers.&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%2Fi.imgur.com%2FjldtXcJ.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%2Fi.imgur.com%2FjldtXcJ.png" alt="Arguments"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  5 - Alias
&lt;/h2&gt;

&lt;p&gt;Sometimes in a query, we select the same field multiple times, but each time with a different argument (like in the pic). This will cause naming conflicts, so we need to assign aliases to the fields.&lt;/p&gt;

&lt;p&gt;Aliases can be added to any field.&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%2Fi.imgur.com%2FTEp0pnR.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%2Fi.imgur.com%2FTEp0pnR.png" alt="Alias"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  6 - Fragment
&lt;/h2&gt;

&lt;p&gt;We can wrap "subfields" into a Fragment and reuse them with the spread operator in selections. Useful when we select the same fields over and over again. Think of it as a JS object for GraphQL field names that can be destructured!&lt;/p&gt;

&lt;p&gt;The Fragment is sent to the server alongside the main operation in the &lt;code&gt;query&lt;/code&gt; field of the HTTP request payload.&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%2Fi.imgur.com%2FVBCpQ0L.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%2Fi.imgur.com%2FVBCpQ0L.png" alt="Fragment"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  7 - Variable
&lt;/h2&gt;

&lt;p&gt;Using GraphQL variables makes it easy to modularize and share/reuse our prewritten query code. We declare them at the beginning of a query, and are allowed to assign default values to them. The variables can be nested, just like a normal JSON object.&lt;/p&gt;

&lt;p&gt;Noticed the GraphQL request payload in the pic of section &lt;em&gt;2 - A GraphQL Query Exchange&lt;/em&gt;? This is what the "variables" field is for.&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%2Fi.imgur.com%2FCZ9IXJ1.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%2Fi.imgur.com%2FCZ9IXJ1.png" alt="Variable"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  8 - Interface
&lt;/h2&gt;

&lt;p&gt;Interfaces in a GraphQL schema allow us to flexibly create and use complex data types in an OOP manner.&lt;/p&gt;

&lt;p&gt;Types can implement (multiple) interfaces.&lt;/p&gt;

&lt;p&gt;When the return type is an interface, we can use the &lt;code&gt;on&lt;/code&gt; keyword to conditionally access fields of a specific implementation.&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%2Fi.imgur.com%2FR2W9Kax.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%2Fi.imgur.com%2FR2W9Kax.png" alt="Interface"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  9 - Mutation Operation
&lt;/h2&gt;

&lt;p&gt;Contrary to queries, a Mutation operation is used to change the serverside data - eg. to create an account, generate auth token, or add data entries.&lt;/p&gt;

&lt;p&gt;Like queries, we can supply arguments to a mutation. The mutation also returns value, so don't forget to select the fields we need!&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%2Fi.imgur.com%2FguzWD0X.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%2Fi.imgur.com%2FguzWD0X.png" alt="Mutation Operation"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  10 - Subscription Operation
&lt;/h2&gt;

&lt;p&gt;Instead of sending queries over HTTP back and forth, GraphQL also has a Subscription operation type for creating WebSocket connections, so the server can push continuous updates to the client.&lt;/p&gt;

&lt;p&gt;Particularly useful for real-time apps like 💹 stock market or 💬 messaging apps.&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%2Fi.imgur.com%2FXZ5jtC2.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%2Fi.imgur.com%2FXZ5jtC2.png" alt="Subscription Operation"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  BONUS
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Online Playgrounds
&lt;/h3&gt;

&lt;p&gt;Many GraphQL frameworks come with a web IDE with autocompletion support and interactive schema lookups like &lt;a href="https://github.com/graphql/graphiql" rel="noopener noreferrer"&gt;GraphiQL&lt;/a&gt; or &lt;a href="https://github.com/prisma-labs/graphql-playground" rel="noopener noreferrer"&gt;GraphQL Playground&lt;/a&gt;. Make use of them when debugging your queries! ✨ &lt;/p&gt;

&lt;p&gt;You can also create your own playground online with &lt;a href="https://codesandbox.io/" rel="noopener noreferrer"&gt;CodeSandbox&lt;/a&gt; by selecting the &lt;em&gt;Apollo GraphQL Server&lt;/em&gt; sandbox.&lt;/p&gt;

&lt;p&gt;However, if you are as lazy as me 🤪, there are also a few zero-config public GraphQL APIs to play with online 👉 &lt;a href="https://apis.guru/graphql-apis/" rel="noopener noreferrer"&gt;https://apis.guru/graphql-apis/&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Additional Resources
&lt;/h3&gt;

&lt;p&gt;There's a &lt;a href="https://ladybug.dev/episode/what-the-heck-is-graphql/" rel="noopener noreferrer"&gt;great episode&lt;/a&gt; on GraphQL from the &lt;a href="https://ladybug.dev" rel="noopener noreferrer"&gt;Ladybug Podcast&lt;/a&gt;, do check it out!&lt;/p&gt;

&lt;p&gt;I hope you have enjoyed this GraphQL crash course! 😁 Have a great and productive week ahead! 🙌&lt;/p&gt;

&lt;p&gt;(Thread crash course format inspired by &lt;a href="https://twitter.com/chrisachard" rel="noopener noreferrer"&gt;@chrisachard&lt;/a&gt; 😁 Check out his excellent React/Redux, Git crash courses!)&lt;/p&gt;




&lt;p&gt;While you are still here, if you've got 13 more minutes and are interested in learning the new hot framework Svelte, I've also got a crash course with companion videos here 👉 &lt;a href="https://dev.to/hexrcs/svelte-crash-course-with-pics-27cc"&gt;&lt;strong&gt;Svelte Crash Course&lt;/strong&gt; 🔥&lt;/a&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;strong&gt;Like this post?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;I'll be posting more on Twitter: &lt;a href="https://twitter.com/hexrcs" rel="noopener noreferrer"&gt;@hexrcs&lt;/a&gt;&lt;/em&gt;&lt;br&gt;&lt;em&gt;You can also find me at my homepage: &lt;a href="https://www.xiaoru.li" rel="noopener noreferrer"&gt;xiaoru.li&lt;/a&gt;&lt;/em&gt;&lt;br&gt;&lt;/p&gt;

</description>
      <category>graphql</category>
      <category>webdev</category>
      <category>beginners</category>
      <category>javascript</category>
    </item>
    <item>
      <title>⏰ Svelte Crash Course (in 10 pics!)</title>
      <dc:creator>hexrcs</dc:creator>
      <pubDate>Sat, 19 Oct 2019 19:58:42 +0000</pubDate>
      <link>https://dev.to/methodcoder/svelte-crash-course-with-pics-27cc</link>
      <guid>https://dev.to/methodcoder/svelte-crash-course-with-pics-27cc</guid>
      <description>&lt;p&gt;&lt;em&gt;Originally posted on Twitter as a thread: &lt;a href="https://twitter.com/hexrcs/status/1185186492982943744" rel="noopener noreferrer"&gt;https://twitter.com/hexrcs/status/1185186492982943744&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  Huge Update: Video Version Now Available!
&lt;/h3&gt;

&lt;p&gt;👉 &lt;strong&gt;&lt;a href="https://www.youtube.com/playlist?list=PLyNmzPg2z6OiXylVCmsUOpaXdZm7lrzCt" rel="noopener noreferrer"&gt;YouTube Playlist&lt;/a&gt; - Only 13 minutes in total!&lt;/strong&gt; 🥳&lt;/p&gt;




&lt;p&gt;Always wanted to check out Svelte (aka. "the next big thing in web dev") but never got time for it? ⏰&lt;/p&gt;

&lt;p&gt;🔥 I've got a 10-minute crash course for you! 👇&lt;/p&gt;

&lt;p&gt;(Spoiler alert: Svelte is so intuitive and easy to use that you may feel like you already know it! 🥳)&lt;/p&gt;

&lt;h2&gt;
  
  
  1 - How Svelte works
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Compiler: Doesn't ship a Svelte "library" to users, but build-time optimized plain JS&lt;/li&gt;
&lt;li&gt;Components: App is made up of composable UI elements&lt;/li&gt;
&lt;li&gt;Reactive: Event/User interaction triggers chain of state changes, auto-updating components throughout the entire app&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%2Fi.imgur.com%2FgEKNr2S.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%2Fi.imgur.com%2FgEKNr2S.png" alt="How Svelte works"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  2 - UI Is a Component Tree
&lt;/h2&gt;

&lt;p&gt;A &lt;em&gt;component&lt;/em&gt; defines how your app should interpret some abstract "state" values, so that it can turn them into DOM elements in your browser, and ultimately pixels on your screen.&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%2Fi.imgur.com%2FPVb4NIr.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%2Fi.imgur.com%2FPVb4NIr.png" alt="UI Is a Component Tree"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  3 - The Anatomy of a Svelte Component
&lt;/h2&gt;

&lt;p&gt;Each &lt;code&gt;.svelte&lt;/code&gt; file contains a single component, consisting of 3 parts:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;&amp;lt;script&amp;gt;&lt;/code&gt; is component logic in JS&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;&amp;lt;style&amp;gt;&lt;/code&gt; is CSS styling, scoped and applied to only the current component&lt;/li&gt;
&lt;li&gt;Svelte template, based on HTML but can use custom components and inline logic (like JSX)&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%2Fi.imgur.com%2FZZvHUCb.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%2Fi.imgur.com%2FZZvHUCb.png" alt="The Anatomy of a Svelte Component"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  4 - The Svelte Template
&lt;/h2&gt;

&lt;p&gt;The Svelte template allows us to use our own custom components in addition to HTML elements. The &lt;code&gt;.svelte&lt;/code&gt; file extension is optional if there's no ambiguity, but the first letter of a custom component MUST be in uppercase.&lt;/p&gt;

&lt;p&gt;We can use JS expressions inside curly braces &lt;code&gt;{ }&lt;/code&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%2Fi.imgur.com%2FrQUIWsK.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%2Fi.imgur.com%2FrQUIWsK.png" alt="The Svelte Template"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  5 - Setting "Props"
&lt;/h2&gt;

&lt;p&gt;A common way to "control" how a child component behaves is to pass data into it as props (properties).&lt;/p&gt;

&lt;p&gt;To accept a prop, expose a variable with &lt;code&gt;export&lt;/code&gt;. It's important to use &lt;code&gt;let&lt;/code&gt; because &lt;code&gt;const&lt;/code&gt; is not reassignable.&lt;/p&gt;

&lt;p&gt;Setting a prop is just like doing regular HTML.&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%2Fi.imgur.com%2FJtHdsPk.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%2Fi.imgur.com%2FJtHdsPk.png" alt="Setting "&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  6 - Updating Component States
&lt;/h2&gt;

&lt;p&gt;User actions trigger events. &lt;code&gt;on:&lt;/code&gt; lets us listen to events and fire functions to update states. State changes will auto-update the UI.&lt;/p&gt;

&lt;p&gt;Data generally flows from a parent to a child, but we can use &lt;code&gt;bind:&lt;/code&gt; to simplify the state-update logic by allowing two-way data flow.&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%2Fi.imgur.com%2Fj3MARwh.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%2Fi.imgur.com%2Fj3MARwh.png" alt="Updating Component States"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  7 - &lt;code&gt;$:&lt;/code&gt; Reactive Statements
&lt;/h2&gt;

&lt;p&gt;"Reactive statements" are those statements marked by &lt;code&gt;$:&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Svelte analyzes which variables they depend on. When any of those dependencies changes, the corresponding reactive statements will be rerun. Very useful for declaring derived states, or triggering "side effects".&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%2Fi.imgur.com%2FCUjXeFs.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%2Fi.imgur.com%2FCUjXeFs.png" alt="Reactive Statements"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  8 - Reactive State "Store"
&lt;/h2&gt;

&lt;p&gt;A reactive "store" makes it easy to share states across many components. It can exist in a separate JS file. To create a store, just wrap &lt;code&gt;writable&lt;/code&gt; around a value.&lt;/p&gt;

&lt;p&gt;In a component, we prefix store names with a &lt;code&gt;$&lt;/code&gt; in order to directly use or update them. Compiler magic!&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%2Fi.imgur.com%2FkHV9MTq.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%2Fi.imgur.com%2FkHV9MTq.png" alt="Reactive State "&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  9 - Conditional Rendering And Lists
&lt;/h2&gt;

&lt;p&gt;We can conditionally render elements with Svelte's template via &lt;code&gt;{#if}&lt;/code&gt; and optionally &lt;code&gt;{:else}&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;To render everything in a list, we have &lt;code&gt;{#each}&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Remember to always close a block with &lt;code&gt;{/if}&lt;/code&gt; or &lt;code&gt;{/each}&lt;/code&gt;!&lt;/p&gt;

&lt;p&gt;(Should've used &lt;code&gt;&amp;lt;ol&amp;gt;&lt;/code&gt; in the example, but I wanted to show how index- access works.)&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%2Fi.imgur.com%2FlkdkmAR.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%2Fi.imgur.com%2FlkdkmAR.png" alt="Conditional Rendering And Lists"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  10 - Elegant Async/Await
&lt;/h2&gt;

&lt;p&gt;It's super easy to do asynchronous stuff like API requests with Svelte.&lt;/p&gt;

&lt;p&gt;We can simply &lt;code&gt;{#await}&lt;/code&gt; a Promise to resolve, displaying a &lt;em&gt;"loading"&lt;/em&gt; placeholder before the result is ready.&lt;/p&gt;

&lt;p&gt;Note that we await the Promise in the template section, so no &lt;code&gt;await&lt;/code&gt; keyword in &lt;code&gt;&amp;lt;script&amp;gt;&lt;/code&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%2Fi.imgur.com%2F6OPtzdV.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%2Fi.imgur.com%2F6OPtzdV.png" alt="Elegant Async/Await"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  BONUS - Animated Transitions
&lt;/h2&gt;

&lt;p&gt;Svelte comes with neat animated transitions built-in. Try giving your components a &lt;code&gt;transition:fly&lt;/code&gt; property! There're also other types like fade, slide, etc. You can also use &lt;code&gt;in:&lt;/code&gt; &lt;code&gt;out:&lt;/code&gt; to separately define intro/outros.&lt;/p&gt;

&lt;p&gt;Attached to the transition prop are the params.&lt;/p&gt;

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

&lt;h2&gt;
  
  
  👆 That's All, Folks!
&lt;/h2&gt;

&lt;p&gt;That's it - everything you need to get started with Svelte! 😁&lt;/p&gt;

&lt;p&gt;We covered a lot in this crash course, from the most fundamental concepts to topics that might even be considered intermediate or advanced in other frameworks (eg. API requests and animated transitions).&lt;/p&gt;

&lt;p&gt;Now it's your turn to play with Svelte and build something cool. The &lt;a href="https://svelte.dev/repl" rel="noopener noreferrer"&gt;Svelte REPL&lt;/a&gt; is a great place to start!&lt;/p&gt;

&lt;p&gt;Have fun! 🥳&lt;/p&gt;

&lt;p&gt;(Thread crash course format inspired by &lt;a href="https://twitter.com/chrisachard" rel="noopener noreferrer"&gt;@chrisachard&lt;/a&gt; 😁 Check out his excellent React/Redux, Git crash courses!)&lt;/p&gt;

&lt;h2&gt;
  
  
  PS
&lt;/h2&gt;

&lt;p&gt;Because Svelte is so expressive, I &lt;a href="https://twitter.com/hexrcs/status/1180226461665566721" rel="noopener noreferrer"&gt;joked the other day&lt;/a&gt; that Svelte devs count "characters of code", instead of "lines of code"...&lt;/p&gt;

&lt;p&gt;True that! Here are a few tweet-sized Svelte applets Tomasz Łakomy (&lt;a href="https://twitter.com/tlakomy" rel="noopener noreferrer"&gt;@tlakomy&lt;/a&gt;) and I (&lt;a href="https://twitter.com/hexrcs" rel="noopener noreferrer"&gt;@hexrcs&lt;/a&gt;) have been playing with -&lt;/p&gt;

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

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



&lt;/p&gt;

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

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



&lt;/p&gt;

&lt;p&gt;So, what's the most complex Svelte app that we can fit in a tweet? 😁&lt;/p&gt;

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

&lt;p&gt;&lt;strong&gt;Like this post?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;I'll be posting more on Twitter: &lt;a href="https://twitter.com/hexrcs" rel="noopener noreferrer"&gt;@hexrcs&lt;/a&gt;&lt;/em&gt;&lt;br&gt;&lt;em&gt;You can also find me at my homepage: &lt;a href="https://www.xiaoru.li" rel="noopener noreferrer"&gt;xiaoru.li&lt;/a&gt;&lt;/em&gt;&lt;br&gt;&lt;/p&gt;

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