<?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: Michele Da Rin</title>
    <description>The latest articles on DEV Community by Michele Da Rin (@daudr).</description>
    <link>https://dev.to/daudr</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%2F161303%2F43b7680e-1704-4ef2-b5fe-a75482d4a594.jpeg</url>
      <title>DEV Community: Michele Da Rin</title>
      <link>https://dev.to/daudr</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/daudr"/>
    <language>en</language>
    <item>
      <title>Set a shared background in your Flutter app</title>
      <dc:creator>Michele Da Rin</dc:creator>
      <pubDate>Sat, 12 Sep 2020 10:00:00 +0000</pubDate>
      <link>https://dev.to/daudr/set-a-shared-background-in-your-flutter-app-2gg1</link>
      <guid>https://dev.to/daudr/set-a-shared-background-in-your-flutter-app-2gg1</guid>
      <description>&lt;p&gt;In the last months I started building apps for my clients in &lt;strong&gt;&lt;a href="https://flutter.dev"&gt;Flutter&lt;/a&gt;&lt;/strong&gt;, I have to say that for the time being I’m in love with this library that Google has built. But I was having an hard time figuring out how to set a background that would persint in various pages of my app.&lt;br&gt;&lt;br&gt;
Keep reading to learn how I did it in my latest apps.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--qNfCE-KK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://images.unsplash.com/photo-1500462918059-b1a0cb512f1d%3Fauto%3Dformat%26fit%3Dcrop%26w%3D1950%26q%3D80" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--qNfCE-KK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://images.unsplash.com/photo-1500462918059-b1a0cb512f1d%3Fauto%3Dformat%26fit%3Dcrop%26w%3D1950%26q%3D80" alt="Set the right background for your app"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Photo by &lt;a href="https://unsplash.com/@efekurnaz"&gt;Efe Kurnaz&lt;/a&gt; on &lt;a href="https://unsplash.com"&gt;Unsplash&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2&gt;
  
  
  Understading flutter: Widgets
&lt;/h2&gt;

&lt;p&gt;Flutter is made of &lt;strong&gt;&lt;code&gt;Widgets&lt;/code&gt;&lt;/strong&gt; , these are like &lt;strong&gt;lego bricks&lt;/strong&gt; , you put one above each other to build your &lt;strong&gt;unique app interface&lt;/strong&gt;.&lt;br&gt;&lt;br&gt;
The basic widget of Flutter is &lt;code&gt;MaterialApp&lt;/code&gt; if your using Material design, &lt;strong&gt;this widget tells how to render the App on the phones and which pages you can navigate to, if you use named navigator (highly recommended)&lt;/strong&gt;.&lt;/p&gt;
&lt;h2&gt;
  
  
  Scaffold widget to the rescue
&lt;/h2&gt;

&lt;p&gt;Another basic widget that you’ll find in every Flutter application is &lt;code&gt;Scaffold&lt;/code&gt;, it lets you put your widgets on the screen, and it has &lt;strong&gt;natively implementations of &lt;code&gt;AppBars&lt;/code&gt;, &lt;code&gt;BottomNavigationsAppBars&lt;/code&gt; and &lt;code&gt;Drawers&lt;/code&gt;&lt;/strong&gt;. That’s really something awesome.&lt;br&gt;&lt;br&gt;
So lets keep it up, each &lt;code&gt;Scaffold&lt;/code&gt; has one required field: &lt;code&gt;body&lt;/code&gt;, it’s a generic &lt;code&gt;Widget&lt;/code&gt; that’ll be put at the top left on your screen if you don’t tell nothing to Flutter.&lt;/p&gt;

&lt;p&gt;Here’s an example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import 'package:flutter/material.dart';

class MyScaffold extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(),
        body: Container(
          child: Text('Hi world!'),
        ));
  }
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This basically tells to render a Text on the top left of your screen. See it yourself:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--jKBhb96d--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://firebasestorage.googleapis.com/v0/b/daudr-blog.appspot.com/o/flutter-shared-background%252Fscaffold.png%3Falt%3Dmedia%26token%3Db0263e1a-298b-475e-a843-1da6773ca07f" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--jKBhb96d--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://firebasestorage.googleapis.com/v0/b/daudr-blog.appspot.com/o/flutter-shared-background%252Fscaffold.png%3Falt%3Dmedia%26token%3Db0263e1a-298b-475e-a843-1da6773ca07f" alt="A scaffold saying Hi world!"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That been said it’s time to pass to the argument of this post, how can we use the informations we have to share an image as background throughout our application?&lt;br&gt;&lt;br&gt;
The answer is quite simple really, all we have to do is use another basic flutter’s widget: &lt;strong&gt;&lt;code&gt;Stack&lt;/code&gt;&lt;/strong&gt;.&lt;/p&gt;
&lt;h2&gt;
  
  
  Another widget: Stack
&lt;/h2&gt;

&lt;p&gt;What Stack allows us to do is to simply put widgets on top of each other.&lt;br&gt;&lt;br&gt;
There are three ways to render our widgets in flutter: &lt;strong&gt;&lt;code&gt;Row&lt;/code&gt;, &lt;code&gt;Column&lt;/code&gt; and &lt;code&gt;Stack&lt;/code&gt;&lt;/strong&gt; , but that’s not the argument of this post and the informations about these widget can be easily seen on flutter documentation.&lt;/p&gt;
&lt;h2&gt;
  
  
  How can we use Stack for our porpuse
&lt;/h2&gt;

&lt;p&gt;What can we do now is &lt;strong&gt;use the Scaffold widget to render a body with a Stack by default, and the stack children being an &lt;code&gt;Image&lt;/code&gt; widget and a &lt;code&gt;Container&lt;/code&gt; widget&lt;/strong&gt;.&lt;br&gt;&lt;br&gt;
The Image widget will render an image which will cover all of our phone’s screen and the Container will take all the screen’s space to render other widgets on top of ou image, using it as a background.Here’s the code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import 'package:flutter/material.dart';

class MyScaffold extends StatelessWidget {
  final Widget child;
  final String image;

  ModelToysScaffold(
      {@required this.child,
      this.image = 'assets/images/background.png',});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(), =&amp;gt;
      body: Stack(
        children: [
          Positioned(
            top: 0,
            child: Image.asset(
              image,
              height: MediaQuery.of(context).size.height,
              width: MediaQuery.of(context).size.width,
              fit: BoxFit.cover,
            ),
          ),
          Container(
            width: MediaQuery.of(context).size.width,
            height: MediaQuery.of(context).size.height,
            child: child,
          ),
        ],
      ),
    );
  }
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Here’s the result:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--jlvyoJxR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://firebasestorage.googleapis.com/v0/b/daudr-blog.appspot.com/o/flutter-shared-background%252Fscaffold-background.png%3Falt%3Dmedia%26token%3D6846a0fd-e091-442a-8689-f17289875978" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--jlvyoJxR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://firebasestorage.googleapis.com/v0/b/daudr-blog.appspot.com/o/flutter-shared-background%252Fscaffold-background.png%3Falt%3Dmedia%26token%3D6846a0fd-e091-442a-8689-f17289875978" alt="Our text has now a background"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;What do you think of this approach?&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Let me know in the comments!&lt;/strong&gt; 😉&lt;/p&gt;

</description>
      <category>flutter</category>
      <category>android</category>
      <category>ios</category>
      <category>scaffold</category>
    </item>
    <item>
      <title>How to Create your first GatsbyJS Plugin</title>
      <dc:creator>Michele Da Rin</dc:creator>
      <pubDate>Tue, 15 Oct 2019 12:23:42 +0000</pubDate>
      <link>https://dev.to/daudr/how-to-create-your-first-gatsbyjs-plugin-1ij0</link>
      <guid>https://dev.to/daudr/how-to-create-your-first-gatsbyjs-plugin-1ij0</guid>
      <description>&lt;p&gt;&lt;a href="https://blog.daudr.me/create-gatsby-plugin"&gt;&lt;strong&gt;This article has been previously been published on my main blog&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://blog.daudr.me/it/create-gatsby-plugin"&gt;&lt;strong&gt;Questo articolo è stato pubblicato precedentemente nel mio blog principale&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the &lt;a href="https://blog.daudr.me/future-of-web-moentizetion"&gt;latest article&lt;/a&gt;, I introduced the new (proposed) web standard per &lt;strong&gt;Web Monetization&lt;/strong&gt;. In this new article, we'll see how we can create a simple &lt;strong&gt;GatsbyJS Plugin&lt;/strong&gt; to inject the &lt;strong&gt;Web Monetization Meta Tag&lt;/strong&gt; using the &lt;strong&gt;SSR APIs&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--CJgnuqto--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://images.unsplash.com/photo-1494059980473-813e73ee784b%3Fixlib%3Drb-1.2.1%26ixid%3DeyJhcHBfaWQiOjEyMDd9%26auto%3Dformat%26fit%3Dcrop%26w%3D1049%26q%3D80" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--CJgnuqto--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://images.unsplash.com/photo-1494059980473-813e73ee784b%3Fixlib%3Drb-1.2.1%26ixid%3DeyJhcHBfaWQiOjEyMDd9%26auto%3Dformat%26fit%3Dcrop%26w%3D1049%26q%3D80" alt="Add a piece to the puzzle"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Photo by &lt;a href="https://unsplash.com/@sloppyperfectionist"&gt;Hans-Peter Gauster&lt;/a&gt; on &lt;a href="https://unsplash.com"&gt;Unsplash&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Create the plugin files
&lt;/h2&gt;

&lt;p&gt;We can read from the &lt;a href="https://www.gatsbyjs.org/docs/creating-plugins/"&gt;official plugins docs&lt;/a&gt; that a plugin project has to comprehend some files:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;package.json&lt;/code&gt; - &lt;strong&gt;required&lt;/strong&gt; this can be an empty object (&lt;code&gt;{}&lt;/code&gt;) for local plugins.
Also, your &lt;code&gt;package.json&lt;/code&gt; file should have the following properties:

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;name&lt;/code&gt; is used to identify the plugin when it mutates Gatsby’s GraphQL data structure
if &lt;code&gt;name&lt;/code&gt; isn’t set, the folder name for the plugin is used&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;main&lt;/code&gt; is the &lt;a href="https://docs.npmjs.com/creating-node-js-modules#create-the-file-that-will-be-loaded-when-your-module-is-required-by-another-application"&gt;name of the file that will be loaded when your module is required by another application&lt;/a&gt;
if &lt;code&gt;main&lt;/code&gt; isn’t set, a default name of &lt;code&gt;index.js&lt;/code&gt; will be used
if &lt;code&gt;main&lt;/code&gt; isn’t set, it is recommended to create an empty index.js file with the contents &lt;code&gt;//no-op&lt;/code&gt; (short for no-operation), as seen in &lt;a href="https://github.com/gatsbyjs/gatsby/tree/817a6c14543c73ea8f56c9f93d401b03adb44e9d/packages/gatsby-source-wikipedia"&gt;this example plugin&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;version&lt;/code&gt; is used to manage the cache — if it changes, the cache is cleared
if &lt;code&gt;version&lt;/code&gt; isn’t set, an MD5 hash of the &lt;code&gt;gatsby-*&lt;/code&gt; file contents is used to invalidate the cache
omitting the &lt;code&gt;version&lt;/code&gt; field is recommended for local plugins&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;keywords&lt;/code&gt; is used to make your plugin discoverable
plugins published on the npm registry should have &lt;code&gt;gatsby&lt;/code&gt; and &lt;code&gt;gatsby-plugin&lt;/code&gt; in the keywords field to be added to the &lt;a href="https://www.gatsbyjs.org/packages/"&gt;Plugin Library&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;gatsby-browser.js&lt;/code&gt; — usage details are in the &lt;a href="https://www.gatsbyjs.org/docs/browser-apis/"&gt;&lt;code&gt;browser API reference&lt;/code&gt;&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;gatsby-node.js&lt;/code&gt; — usage details are in the &lt;a href="https://www.gatsbyjs.org/docs/node-apis/"&gt;&lt;code&gt;Node API reference&lt;/code&gt;&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;gatsby-ssr.js&lt;/code&gt; — usage details are in the &lt;a href="https://www.gatsbyjs.org/docs/ssr-apis/"&gt;&lt;code&gt;SSR API reference&lt;/code&gt;&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For the sake of this plugin, we'll use only the SSR APIs, therefore, the only file we need to have is the &lt;code&gt;gatsby-ssr.js&lt;/code&gt;' one.&lt;/p&gt;

&lt;h2&gt;
  
  
  Using SSR APIs
&lt;/h2&gt;

&lt;p&gt;As already said we'll create a plugin that'll need only the SSR APIs, GatsbyJS expose these APIs:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.gatsbyjs.org/docs/ssr-apis/#onPreRenderHTML"&gt;&lt;code&gt;onPreRenderHTML&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.gatsbyjs.org/docs/ssr-apis/#onRenderBody"&gt;&lt;code&gt;onRenderBody&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.gatsbyjs.org/docs/ssr-apis/#replaceRenderer"&gt;&lt;code&gt;replaceRenderer&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.gatsbyjs.org/docs/ssr-apis/#wrapPageElement"&gt;&lt;code&gt;wrapPageElement&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.gatsbyjs.org/docs/ssr-apis/#wrapRootElement"&gt;&lt;code&gt;wrapRootElement&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In our plugin, we'll use only the &lt;code&gt;onPreRenderHTML&lt;/code&gt; in order to add the &lt;strong&gt;Web Monetization Meta Tag&lt;/strong&gt; in the &lt;code&gt;&amp;lt;head&amp;gt;&lt;/code&gt; section of our pages.&lt;br&gt;
This API gives us an Object containing two methods and a string that we can use to do what we need:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;getHeadComponents&lt;/code&gt; - return the &lt;code&gt;headComponents&lt;/code&gt; array, formed by &lt;code&gt;ReactNode&lt;/code&gt; objects&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;replaceHeadComponents&lt;/code&gt; - Takes an array of components as its first argument which replaces the headComponents array which is passed to the &lt;code&gt;html.js&lt;/code&gt; component.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;pathname&lt;/code&gt; - Is the current path that's being generated by Gatsby SSR APIs&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can read more on these in &lt;a href="https://www.gatsbyjs.org/docs/ssr-apis/"&gt;the official docs&lt;/a&gt;.&lt;/p&gt;
&lt;h2&gt;
  
  
  Create our SSR file
&lt;/h2&gt;

&lt;p&gt;At the end our &lt;code&gt;gatsby-ssr.js&lt;/code&gt; should look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;onPreRenderHTML&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;reporter&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;getHeadComponents&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;replaceHeadComponents&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;pathname&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="nx"&gt;pluginOptions&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;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;NODE_ENV&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="s2"&gt;`production`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;reporter&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;warn&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;non production environment&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;null&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;pluginOptions&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;paymentPointer&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;reporter&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;warn&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
      &lt;span class="s2"&gt;`Payment Pointer is not defined, add it to your gatsby-config.js file.`&lt;/span&gt;
    &lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;null&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="nx"&gt;pluginOptions&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;excludedPaths&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;pluginOptions&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;excludedPaths&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;0&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;excludedPaths&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;pluginOptions&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;excludedPaths&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;isExcluded&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;excludedPaths&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;path&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;pathname&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;match&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;path&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;0&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;isExcluded&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;null&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;headComponents&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;getHeadComponents&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;webMonetizationTag&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;lt;&lt;/span&gt;&lt;span class="nx"&gt;meta&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;monetization&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;content&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;pluginOptions&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;paymentPointer&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;  &lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="nx"&gt;headComponents&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;webMonetizationTag&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="nx"&gt;replaceHeadComponents&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;headComponents&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;This plugin adds the &lt;strong&gt;Web Monetization Meta Tag&lt;/strong&gt; only when it's run on &lt;code&gt;peoduction&lt;/code&gt; environment (when we use &lt;code&gt;gatsby build&lt;/code&gt;, for example) and accepts an array of strings (&lt;code&gt;excludedPaths&lt;/code&gt;), in its configuration, which tells which paths should not have the meta tag.&lt;/p&gt;

&lt;h2&gt;
  
  
  Use the plugin in your Gatsby Site
&lt;/h2&gt;

&lt;p&gt;In order to use your new plugin you have to install it through &lt;code&gt;npm&lt;/code&gt; first:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;npm i gatsby-plugin-web-monetization
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;And then you have to add it in your &lt;code&gt;gatsby-config.js&lt;/code&gt; file like you already do for all the other plugins.&lt;br&gt;
This plugin in particular can be instantiated like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// Other content ...&lt;/span&gt;
  &lt;span class="na"&gt;plugins&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="c1"&gt;// Other plugins ...&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;`gatsby-plugin-web-monetization`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;options&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;paymentPointer&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;`YOUR_ILP_PAYMENT_POINTER`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;excludedPaths&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;exclude&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;path&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="c1"&gt;// Optional&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;h2&gt;
  
  
  Publish your new plugin on NPM
&lt;/h2&gt;

&lt;p&gt;In order to publish your new plugin on NPM and make it discoverable by its users, you should first add the fields said above in your &lt;code&gt;package.json&lt;/code&gt; file and then you can run &lt;code&gt;npm publish&lt;/code&gt; from the root of your project to publish your new plugin to NPM register. (You have to be logged in to NPM of course 😉)&lt;/p&gt;

&lt;h2&gt;
  
  
  That's all 😎😎😎
&lt;/h2&gt;

&lt;p&gt;Congratulations! You've created and published your first GatsbyJS plugin.&lt;/p&gt;

&lt;p&gt;The plugin can also be found on &lt;a href="https://github.com/Daudr/gatsby-plugin-web-monetization"&gt;my GitHub&lt;/a&gt;, leave a ⭐ if you find it useful! 😻&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>gatsby</category>
      <category>npm</category>
    </item>
    <item>
      <title>The Future of Web Advertisement: Web Monetization</title>
      <dc:creator>Michele Da Rin</dc:creator>
      <pubDate>Sat, 12 Oct 2019 05:19:50 +0000</pubDate>
      <link>https://dev.to/daudr/the-future-of-web-advertisement-web-monetization-402n</link>
      <guid>https://dev.to/daudr/the-future-of-web-advertisement-web-monetization-402n</guid>
      <description>&lt;p&gt;&lt;a href="https://blog.daudr.me/future-of-web-monetization/"&gt;&lt;strong&gt;This article has been previously published on my main blog&lt;/strong&gt;.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://blog.daudr.me/it/future-of-web-monetization/"&gt;&lt;strong&gt;Questo articolo è disponibile anche in italiano sul mio blog principale.&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There's a new (proposed) web standard about &lt;strong&gt;advertising on the web&lt;/strong&gt;. It's called &lt;strong&gt;Web Monetization&lt;/strong&gt;, let's see what's all about.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--wXB8vllw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://images.unsplash.com/photo-1560152214-4e76ac668a11%3Fixlib%3Drb-1.2.1%26ixid%3DeyJhcHBfaWQiOjEyMDd9%26auto%3Dformat%26fit%3Dcrop%26w%3D1950%26q%3D80" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--wXB8vllw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://images.unsplash.com/photo-1560152214-4e76ac668a11%3Fixlib%3Drb-1.2.1%26ixid%3DeyJhcHBfaWQiOjEyMDd9%26auto%3Dformat%26fit%3Dcrop%26w%3D1950%26q%3D80" alt="The light at the end of the tunnel"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Photo by &lt;a href="https://unsplash.com/@atlasyao"&gt;Wendong Yao&lt;/a&gt; on &lt;a href="https://unsplash.com/"&gt;Unsplash&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  What is Web Monetization
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Web Monetization&lt;/strong&gt; is a&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;proposed browser API that uses ILP (&lt;strong&gt;Interledger Protocol&lt;/strong&gt;) micropayments to monetize a site. It can be provided through a polyfill or an extension, but the goal is to eventually implement it directly into the user's browser.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Motivation
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;The ability to transfer money has been a long-standing omission from the web platform. As a result, the web suffers from a flood of advertising and corrupt business models. Web Monetization provides an open, native, efficient, and automatic way to compensate creators, pay for API calls, and support crucial web infrastructure.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  How Web Monetization can improve users satisfaction
&lt;/h2&gt;

&lt;p&gt;Web Monetization can improve the user overall satisfaction with your web content because he won't be persecuted by your ads, and you still will make money from him.&lt;/p&gt;

&lt;p&gt;In fact, Web Monetization offers the user to choose where its web monetization funds should go when navigating the web.&lt;/p&gt;

&lt;h2&gt;
  
  
  Web Monetization Wallets
&lt;/h2&gt;

&lt;p&gt;At the moment these are the &lt;strong&gt;Web Monetization Wallets&lt;/strong&gt; (wallets that accepts &lt;strong&gt;ILP Payments&lt;/strong&gt;):&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.xrptipbot.com/"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--QejtUbBK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://firebasestorage.googleapis.com/v0/b/daudr-blog.appspot.com/o/future-of-web-monetization%252Ftipbot_logo.png%3Falt%3Dmedia%26token%3D8aab0f55-43fd-40c5-86bc-737b269dae4a" alt="XRP Tipbot"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;XRP Tipbot&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://gatehub.net/"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--kivb1peX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://firebasestorage.googleapis.com/v0/b/daudr-blog.appspot.com/o/future-of-web-monetization%252Fgatehub_logo.png%3Falt%3Dmedia%26token%3D39082cb3-4d96-4971-b0c2-ed094931823f" alt="GateHub"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;GateHub&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://stronghold.co/"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--s8X_lrqA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://firebasestorage.googleapis.com/v0/b/daudr-blog.appspot.com/o/future-of-web-monetization%252Fstronghold_logo.png%3Falt%3Dmedia%26token%3Dda4d34a1-d874-4a6e-ae5b-ec156bd6f82e" alt="Stronghold"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Stronghold&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Web Monetization Providers
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://coil.com"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--wr5fpv2r--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://firebasestorage.googleapis.com/v0/b/daudr-blog.appspot.com/o/future-of-web-monetization%252Fcoil.png%3Falt%3Dmedia%26token%3Dd95f3a51-0700-430a-8c6d-fef703182a6a" alt="Coil"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;At the moment of writing this article, the only known &lt;strong&gt;Web Monetization Provider&lt;/strong&gt; is &lt;strong&gt;Coil&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Coil&lt;/strong&gt;, like &lt;a href="https://medium.com"&gt;&lt;strong&gt;Medium&lt;/strong&gt;&lt;/a&gt;, is a platform when a person can share articles (or &lt;strong&gt;web monetized links&lt;/strong&gt;) and offers a monthly fee for viewing a sort of pro members' articles only and for paying those web monetized links that you visit.&lt;/p&gt;

&lt;h2&gt;
  
  
  How do I web monetize my own content? 💰
&lt;/h2&gt;

&lt;p&gt;Implementing Web Monetization is quite easy, in fact, this consists in adding only a line to your html files. This new line is called &lt;strong&gt;Web Monetization Meta Tag.&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Setup a Web Monetization Wallet
&lt;/h3&gt;

&lt;p&gt;In order to receive payments you need to set up a &lt;strong&gt;Web Monetization Wallet&lt;/strong&gt;, you can use one of the above.&lt;/p&gt;

&lt;h3&gt;
  
  
  Get your payment pointer
&lt;/h3&gt;

&lt;p&gt;When you finish to set up your new account you'll receive a &lt;strong&gt;Payment Pointer&lt;/strong&gt;. A Payment Pointer looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$coil.xrptipbot.com/C3adA1B9Q5qMu4Z3i4Bfhw
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  Generate your Meta Tag
&lt;/h3&gt;

&lt;p&gt;The Meta tag is the tag we're going to add to our web monetized web pages. This looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;meta&lt;/span&gt;
  &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"monetization"&lt;/span&gt;
  &lt;span class="na"&gt;content=&lt;/span&gt;&lt;span class="s"&gt;"$coil.xrptipbot.com/C3adA1B9Q5qMu4Z3i4Bfhw"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;The tag's &lt;code&gt;name&lt;/code&gt; have to be &lt;code&gt;monetization&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Add your new Meta Tag to your pages
&lt;/h3&gt;

&lt;p&gt;Copy your Meta Tag and add it to your websites' &lt;code&gt;&amp;lt;head&amp;gt;&lt;/code&gt; section. It should look like the example below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="cp"&gt;&amp;lt;!doctype html&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;html&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;title&amp;gt;&lt;/span&gt;Web Monetized Site&lt;span class="nt"&gt;&amp;lt;/title&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;meta&lt;/span&gt;
        &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"monetization"&lt;/span&gt;
        &lt;span class="na"&gt;content=&lt;/span&gt;&lt;span class="s"&gt;"$coil.xrptipbot.com/C3adA1B9Q5qMu4Z3i4Bfhw"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;
  &lt;span class="c"&gt;&amp;lt;!-- Other content --&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Congratulations! Your website is now Web Monetized.&lt;/strong&gt; 😎😎😎&lt;/p&gt;

</description>
      <category>ilp</category>
      <category>crypto</category>
      <category>xrp</category>
      <category>webmonetization</category>
    </item>
    <item>
      <title>News From Firebase Summit 2019</title>
      <dc:creator>Michele Da Rin</dc:creator>
      <pubDate>Sat, 05 Oct 2019 15:02:51 +0000</pubDate>
      <link>https://dev.to/daudr/news-from-firebase-summit-2019-3f34</link>
      <guid>https://dev.to/daudr/news-from-firebase-summit-2019-3f34</guid>
      <description>&lt;p&gt;This article has been previously published on &lt;a href="https://blog.daudr.me/firebase-summit-2019" rel="noopener noreferrer"&gt;my main blog&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://blog.daudr.me/it/firebase-summit-2019" rel="noopener noreferrer"&gt;Questo articolo è disponibile anche in italiano&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The Firebase Summit 2019 took place on the 26th of September in Madrid and I had the honor to attend. In this article, I'll talk about the various (and cool) new features that have been announced.&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%2Ffirebasestorage.googleapis.com%2Fv0%2Fb%2Fdaudr-blog.appspot.com%2Fo%2Fattending-firebase-2019%252Ffirebase-attendee-badge.jpg%3Falt%3Dmedia%26token%3D32b09174-7ffe-404d-90b1-626c1f1f99b2" 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%2Ffirebasestorage.googleapis.com%2Fv0%2Fb%2Fdaudr-blog.appspot.com%2Fo%2Fattending-firebase-2019%252Ffirebase-attendee-badge.jpg%3Falt%3Dmedia%26token%3D32b09174-7ffe-404d-90b1-626c1f1f99b2" alt="Michele Da Rin Fioretto Attendee Badge"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There has been a lot of news on this event, let me tell you about them:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.youtube.com/watch?v=SiPOaV-5j9o" rel="noopener noreferrer"&gt;&lt;strong&gt;A quick video introduction by Firebase&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.youtube.com/watch?v=wO70Pnv0yeo" rel="noopener noreferrer"&gt;&lt;strong&gt;The opening keyonote of the Firebase Summit&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Firebase Emulator Suite
&lt;/h2&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%2Ffirebase.google.com%2Fdocs%2Femulator-suite%2Fimages%2Femulator_suite_block.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%2Ffirebase.google.com%2Fdocs%2Femulator-suite%2Fimages%2Femulator_suite_block.png" alt="Firebase Emulator Suite"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;One of the most interesting additions is &lt;strong&gt;Firebase Emulator Suite&lt;/strong&gt;, this suite will let the developer have faster and safer development experience and don't forget about the speed gained since you'll have everything locally with &lt;strong&gt;Hot Reloading&lt;/strong&gt; when your &lt;strong&gt;Cloud Functions&lt;/strong&gt; or your &lt;strong&gt;Security Rules&lt;/strong&gt; change.&lt;/p&gt;

&lt;p&gt;You'll find a very detailed guid on the new &lt;a href="https://google.dev/playlists/firebase-emulators" rel="noopener noreferrer"&gt;google.dev firebase codelabs&lt;/a&gt; 🤩🤩🤩&lt;/p&gt;

&lt;h2&gt;
  
  
  Firebase Extensions
&lt;/h2&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%2Ffirebase.google.com%2Fimages%2Fproducts%2Fmods%2Fmods-2.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%2Ffirebase.google.com%2Fimages%2Fproducts%2Fmods%2Fmods-2.png" alt="Firebase Extensions"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Another cool update are the &lt;strong&gt;Firebase Extensions&lt;/strong&gt;, these will let you add some functionalities (like translating, resizing images, etc.) without writing a single line of code. Firebase has released these open source, and it plans to let developers create their own extensions, how modular!&lt;/p&gt;

&lt;h2&gt;
  
  
  Google Analytics for Firebase
&lt;/h2&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%2Ffirebase.google.com%2Fimages%2Fproducts%2Fanalytics%2Fanalytics-1.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%2Ffirebase.google.com%2Fimages%2Fproducts%2Fanalytics%2Fanalytics-1.png" alt="Google Analytics for Firebase"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.youtube.com/watch?v=q4Y4PgwlW-Q" rel="noopener noreferrer"&gt;&lt;strong&gt;Introduction to Google Analytics for Firebase&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Another great addition is the possibility to add &lt;strong&gt;Google Analytics&lt;/strong&gt; to your web and native applications. It's a great addition because it'll let you create custom audiences based on your users' usage (and we'll see why this it's important next).&lt;/p&gt;

&lt;h2&gt;
  
  
  Remote Config
&lt;/h2&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%2Ffirebase.google.com%2Fimages%2Fproducts%2Fremote-config%2Fremote-config-1.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%2Ffirebase.google.com%2Fimages%2Fproducts%2Fremote-config%2Fremote-config-1.png" alt="Remote Config"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Also, &lt;strong&gt;Remote config&lt;/strong&gt; is being added to Web projects, it'll let you change the look and feel of your apps by enabling them in just a click, selecting the audience you want to see the changes. You can use the audiences created with Analytics to have a better reach too.&lt;/p&gt;

&lt;h2&gt;
  
  
  Firebase Cloud Messaging
&lt;/h2&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%2Ffirebase.google.com%2Fimages%2Fproducts%2Fcloud-messaging%2Fcloud-messaging-5.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%2Ffirebase.google.com%2Fimages%2Fproducts%2Fcloud-messaging%2Fcloud-messaging-5.png" alt="Firebase Cloud Messaging"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Firebase Cloud Messaging&lt;/strong&gt; will be added to Web Projects too, and it'll let yuo send targeted Messages to users that use your app. It's just like &lt;strong&gt;Push Notifications&lt;/strong&gt;, but better! 💌💌💌&lt;/p&gt;

&lt;h2&gt;
  
  
  Firebase App Distribution
&lt;/h2&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%2Ffirebase.google.com%2Fimages%2Fproducts%2Fapp-distribution%2Fapp-distro-2.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%2Ffirebase.google.com%2Fimages%2Fproducts%2Fapp-distribution%2Fapp-distro-2.png" alt="Firebase App Distibution"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Firebase App Distribution&lt;/strong&gt; will let you release an early preview of your apps to the users you want, and it'll let you see all the stats about the usage of these previews.&lt;/p&gt;

&lt;h2&gt;
  
  
  Firebase Test Lab
&lt;/h2&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%2Ffirebase.google.com%2Fimages%2Fproducts%2Ftest-lab%2Ftest-lab-3.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%2Ffirebase.google.com%2Fimages%2Fproducts%2Ftest-lab%2Ftest-lab-3.png" alt="Firebase Test Lab"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Firebase Test Lab&lt;/strong&gt; is a cloud-based app-testing infrastructure. With one operation, you can test your Android or iOS app across a wide variety of devices and device configurations, and see the results  -  including logs, videos, and screenshots  -  in the Firebase console.&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%2Ffirebasestorage.googleapis.com%2Fv0%2Fb%2Fdaudr-blog.appspot.com%2Fo%2Fattending-firebase-2019%252Ffirebase-test-lab.jpg%3Falt%3Dmedia%26token%3Dc10b2238-c408-4478-bd1a-09261a65540c" 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%2Ffirebasestorage.googleapis.com%2Fv0%2Fb%2Fdaudr-blog.appspot.com%2Fo%2Fattending-firebase-2019%252Ffirebase-test-lab.jpg%3Falt%3Dmedia%26token%3Dc10b2238-c408-4478-bd1a-09261a65540c" alt="Firebase Test Lab at Firebase Summit"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Firebase Test Lab at Firebase Summit&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Test Lab uses real, production devices running in a Google data center to test your app. The devices are flashed with updated APIs and have customizable locale settings, allowing you to road-test your app on the hardware and configurations it'll encounter in real-world use&lt;/p&gt;

&lt;h2&gt;
  
  
  Firebase Predictions
&lt;/h2&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%2Ffirebase.google.com%2Fimages%2Fproducts%2Fpredictions%2Fpredictions-1.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%2Ffirebase.google.com%2Fimages%2Fproducts%2Fpredictions%2Fpredictions-1.png" alt="Firebase Predictions"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Firebase Predictions&lt;/strong&gt; applies &lt;strong&gt;machine learning&lt;/strong&gt; to your analytics data to create dynamic user segments based on your users' predicted behavior. These predictions are automatically available for use with &lt;strong&gt;Firebase Remote Config&lt;/strong&gt;, the &lt;strong&gt;Notifications composer&lt;/strong&gt;, &lt;strong&gt;Firebase In-App Messaging&lt;/strong&gt;, and &lt;strong&gt;A/B Testing&lt;/strong&gt;. You can also export your app's Predictions data to &lt;strong&gt;BigQuery&lt;/strong&gt; for further analysis or to push to third party tools.&lt;/p&gt;

&lt;h2&gt;
  
  
  That's all
&lt;/h2&gt;

&lt;p&gt;That's all from Firebase Summit, but consider registering to my newsletter if you want to keep updated on &lt;strong&gt;Firebase News&lt;/strong&gt; and &lt;strong&gt;Tutorials&lt;/strong&gt; 😍😍😍&lt;/p&gt;

</description>
      <category>firebase</category>
      <category>firebasesummit</category>
      <category>news</category>
    </item>
    <item>
      <title>Painless Angular SSR with Nginx/Apache/Firebase &amp; Angular CLI</title>
      <dc:creator>Michele Da Rin</dc:creator>
      <pubDate>Mon, 12 Aug 2019 10:46:36 +0000</pubDate>
      <link>https://dev.to/daudr/painless-angular-ssr-with-nginx-apache-firebase-angular-cli-4jno</link>
      <guid>https://dev.to/daudr/painless-angular-ssr-with-nginx-apache-firebase-angular-cli-4jno</guid>
      <description>&lt;p&gt;This article has been previously published on &lt;a href="https://blog.daudr.me/painless-angular-ssr" rel="noopener noreferrer"&gt;my main blog&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So you're building a new, phantasmagorical web site (let's say a brand new e-commerce for those absolutely unknown books that you find beautifully written) and you need your future clients to find it on the first search page on Google.&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%2Fimages.unsplash.com%2Fphoto-1544986581-efac024faf62%3Fixlib%3Drb-1.2.1%26ixid%3DeyJhcHBfaWQiOjEyMDd9%26auto%3Dformat%26fit%3Dcrop%26w%3D1950%26q%3D80" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimages.unsplash.com%2Fphoto-1544986581-efac024faf62%3Fixlib%3Drb-1.2.1%26ixid%3DeyJhcHBfaWQiOjEyMDd9%26auto%3Dformat%26fit%3Dcrop%26w%3D1950%26q%3D80" alt="Serve your Angular app right"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Photo by &lt;a href="https://unsplash.com/@alevtakil" rel="noopener noreferrer"&gt;Alev Takil&lt;/a&gt; on &lt;a href="https://unsplash.com" rel="noopener noreferrer"&gt;Unsplash&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;After a lot of research, you decided to use Angular as FE framework because you think it's the best fit for that e-commerce, but when you finally deploy it on production and you search it you don't find even if it's some time that's been published, what's going on?&lt;/p&gt;

&lt;p&gt;Google recently updated its crawler to pre-render javascript Single Page Applications like Angular ones, but this technology doesn't always work well (and you need to know that not everybody uses Google to surf the Internet).&lt;/p&gt;

&lt;h2&gt;
  
  
  Angular Universal to the rescue
&lt;/h2&gt;

&lt;p&gt;Fortunately, the Angular Team built a nice (after some initial troubles) tool that helps us, a tool called &lt;a href="https://angular.io/guide/universal" rel="noopener noreferrer"&gt;Angular Universal&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Setting things up
&lt;/h3&gt;

&lt;p&gt;Setting Angular Universal up is relatively easy, you just to type a single command in your terminal&lt;/p&gt;

&lt;p&gt;&lt;code&gt;ng add @nguniversal/express-engine --clientProject "your project that neeeds SSR"&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This little command generates some files in your &lt;code&gt;src/&lt;/code&gt; folder:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;main.server.ts&lt;/code&gt; -  Bootstrapper of the server app&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;app/app.server.module.ts&lt;/code&gt;  -  Server-side app module&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;server.ts&lt;/code&gt; -  Express web server&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;ts.config.server.json&lt;/code&gt; -  Typescript config for your server app&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;webpack.server.config.js&lt;/code&gt; -  Webpack server configuration&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Verify if the SSR app works
&lt;/h3&gt;

&lt;p&gt;To verify if your brand new Server-Side rendered app will work type in your terminal&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm run build:ssr
npm run serve:ssr
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If all works well (you'd be really lucky) you should see the app working on &lt;code&gt;localhost:4000&lt;/code&gt;, else continue reading to know some error catching.&lt;/p&gt;

&lt;h2&gt;
  
  
  Catching SSR errors
&lt;/h2&gt;

&lt;p&gt;There are plenty of errors that could occur while trying to build our SSR app, let's try to understand the most common ones.&lt;/p&gt;

&lt;h3&gt;
  
  
  Using browser only namespaces
&lt;/h3&gt;

&lt;p&gt;When the app is running in our server there are some standard objects that we cannot use, ie &lt;code&gt;window&lt;/code&gt;, so we can do two things:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Inject false objects to "deceive" the server and make our app working even on the server-side, to do this simply add these lines before the &lt;code&gt;express()&lt;/code&gt; initialization in your &lt;code&gt;server.ts&lt;/code&gt; file:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="p"&gt;...&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;domino&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;domino&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;fs&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;fs&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;path&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;path&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;templateA&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;fs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;readFileSync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;path&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;dist/browser&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;index.html&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)).&lt;/span&gt;&lt;span class="nf"&gt;toString&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;win&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;domino&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;createWindow&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;templateA&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;win&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;Object&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Object&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;win&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;Math&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nb"&gt;global&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;window&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;win&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nb"&gt;global&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;document&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;win&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nb"&gt;global&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;branch&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nb"&gt;global&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;object&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;win&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;object&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;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;express&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;/li&gt;
&lt;li&gt;
&lt;p&gt;Detect the parts where you're using these objects and make them run only in your browser app.&lt;br&gt;
In this case Angular makes us available two methods &lt;code&gt;isPlatformBrowser&lt;/code&gt; and &lt;code&gt;isPlatformServer&lt;/code&gt; exposed by &lt;code&gt;@angular/common&lt;/code&gt;.&lt;br&gt;
Here's a little example:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;Component&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;Inject&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;PLATFORM_ID&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@angular/core&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;isPlatformBrowser&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@angular/common&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="nd"&gt;Component&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
&lt;span class="na"&gt;selector&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;app-root&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="na"&gt;templateUrl&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./app.component.html&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="na"&gt;styleUrls&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./app.component.scss&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="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;AppComponent&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;(@&lt;/span&gt;&lt;span class="nd"&gt;Inject&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;PLATFORM_ID&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="nx"&gt;platformId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;any&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;

    &lt;span class="nf"&gt;onActivate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;any&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="nf"&gt;isPlatformBrowser&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;platformId&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;scrollToTop&lt;/span&gt; &lt;span class="o"&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;setInterval&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;pos&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;pageYOffset&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;pos&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                    &lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;scrollTo&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;pos&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
                &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                    &lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;clearInterval&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;scrollToTop&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="mi"&gt;16&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;p&gt;This snippet runs the scrollTop only if this code runs on the browser.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Finish this all: Deploy to production
&lt;/h2&gt;

&lt;p&gt;The best part arrived, the part where I'll walk you through server configuration, isn't it awesome?&lt;/p&gt;

&lt;h3&gt;
  
  
  Apache Configuration
&lt;/h3&gt;

&lt;p&gt;If you're using Apache as the webserver you need to create or modify your &lt;code&gt;.htaccess&lt;/code&gt; file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;IfModule mod_rewrite.c&amp;gt;
 RewriteEngine On
 # If an existing asset or directory is requested go to it as it is
 RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -f [OR]
 RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -d
 RewriteRule ^ - [L]

 RewriteRule ^ /dist/browser/index.html
&amp;lt;/IfModule&amp;gt;
&amp;lt;VirtualHost *:80&amp;gt;
 ServerName example.com # &amp;lt;-- modify here
 ServerAlias www.example.com # &amp;lt;-- modiy here
 &amp;lt;Proxy *&amp;gt;
  Order allow,deny
  Allow from all
 &amp;lt;/Proxy&amp;gt;
 ProxyPreserveHost On
 ProxyRequests Off
 ProxyPass / http://localhost:4000/
 ProxyPassReverse / http://localhost:4000/
&amp;lt;/VirtualHost&amp;gt;

&amp;lt;VirtualHost *:443&amp;gt;
 ServerName example.com # &amp;lt;-- modify here
 ServerAlias www.example.com # &amp;lt;-- modify here
 &amp;lt;Proxy *&amp;gt;
  Order allow,deny
  Allow from all
 &amp;lt;/Proxy&amp;gt;
 ProxyPreserveHost On
 ProxyRequests Off
 ProxyPass / https://localhost:4000/
 ProxyPassReverse / https://localhost:4000/
&amp;lt;/VirtualHost&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Nginx configuration
&lt;/h3&gt;

&lt;p&gt;In case you using Nginx instead you need to configure the configuration under the &lt;code&gt;/etc/nginx/sites-available/www.example.com&lt;/code&gt; file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight nginx"&gt;&lt;code&gt;&lt;span class="k"&gt;upstream&lt;/span&gt; &lt;span class="s"&gt;your_upstream_config&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
 &lt;span class="kn"&gt;server&lt;/span&gt; &lt;span class="nf"&gt;127.0.0.1&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;4000&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;server&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
 &lt;span class="kn"&gt;listen&lt;/span&gt; &lt;span class="mi"&gt;443&lt;/span&gt; &lt;span class="s"&gt;ssl&lt;/span&gt; &lt;span class="s"&gt;http2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
 &lt;span class="kn"&gt;server_name&lt;/span&gt; &lt;span class="s"&gt;www.example.com&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;# &amp;lt;--- modify here&lt;/span&gt;
 &lt;span class="kn"&gt;root&lt;/span&gt; &lt;span class="n"&gt;/home/"your&lt;/span&gt; &lt;span class="s"&gt;user"/path/to/dist/browser&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
 &lt;span class="kn"&gt;location&lt;/span&gt; &lt;span class="n"&gt;/&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kn"&gt;try_files&lt;/span&gt; &lt;span class="nv"&gt;$uri&lt;/span&gt; &lt;span class="nv"&gt;$uri&lt;/span&gt; &lt;span class="s"&gt;@backend&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
 &lt;span class="p"&gt;}&lt;/span&gt;

 &lt;span class="kn"&gt;location&lt;/span&gt; &lt;span class="s"&gt;@backend&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kn"&gt;proxy_pass&lt;/span&gt; &lt;span class="s"&gt;http://your_upstream_config&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kn"&gt;proxy_set_header&lt;/span&gt; &lt;span class="s"&gt;X-Real-IP&lt;/span&gt; &lt;span class="nv"&gt;$remote_addr&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kn"&gt;proxy_set_header&lt;/span&gt; &lt;span class="s"&gt;X-Forwarded-For&lt;/span&gt; &lt;span class="nv"&gt;$proxy_add_x_forwarded_for&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kn"&gt;proxy_set_header&lt;/span&gt; &lt;span class="s"&gt;Host&lt;/span&gt; &lt;span class="nv"&gt;$http_host&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kn"&gt;proxy_http_version&lt;/span&gt; &lt;span class="mf"&gt;1.1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kn"&gt;proxy_set_header&lt;/span&gt; &lt;span class="s"&gt;X-NginX-Proxy&lt;/span&gt; &lt;span class="s"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kn"&gt;proxy_set_header&lt;/span&gt; &lt;span class="s"&gt;Upgrade&lt;/span&gt; &lt;span class="nv"&gt;$http_upgrade&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kn"&gt;proxy_set_header&lt;/span&gt; &lt;span class="s"&gt;Connection&lt;/span&gt; &lt;span class="s"&gt;"upgrade"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kn"&gt;proxy_cache_bypass&lt;/span&gt; &lt;span class="nv"&gt;$http_upgrade&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kn"&gt;proxy_redirect&lt;/span&gt; &lt;span class="no"&gt;off&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kn"&gt;proxy_set_header&lt;/span&gt; &lt;span class="s"&gt;X-Forwarded-Proto&lt;/span&gt; &lt;span class="nv"&gt;$scheme&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;server&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
 &lt;span class="kn"&gt;listen&lt;/span&gt; &lt;span class="mi"&gt;80&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
 &lt;span class="kn"&gt;server_name&lt;/span&gt; &lt;span class="s"&gt;www.example.com&lt;/span&gt; &lt;span class="c1"&gt;# &amp;lt;-- modify here&lt;/span&gt;
 &lt;span class="s"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;301&lt;/span&gt; &lt;span class="s"&gt;https://&lt;/span&gt;&lt;span class="nv"&gt;$server_name$request_uri&lt;/span&gt;&lt;span class="s"&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;h2&gt;
  
  
  Bonus - Firebase config 🤩🤩🤩
&lt;/h2&gt;

&lt;p&gt;If you're using Firebase hosting there are some things we have to add and two ways you can accomplish what you've already done with Apache or Nginx: AppEngine or Cloud Functions.&lt;/p&gt;

&lt;h3&gt;
  
  
  Polyfills your firebase project
&lt;/h3&gt;

&lt;p&gt;Firebase uses Websockets and XHR not included in Angular that we need to polyfill. So we run in our terminal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install &lt;/span&gt;ws xhr2 bufferutil utf-8-validate &lt;span class="nt"&gt;-D&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and we add these two new lines to our &lt;code&gt;server.ts&lt;/code&gt; files:&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="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;global&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="kr"&gt;any&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;WebSocket&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;ws&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="nb"&gt;global&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="kr"&gt;any&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;XMLHttpRequest&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;xhr2&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;...&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Deploy on AppEngine
&lt;/h3&gt;

&lt;p&gt;Add a &lt;code&gt;app.yaml&lt;/code&gt; at the root of the project with this line:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;runtime&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;nodejs10&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And then, after you install the Google Cloud CLI, run in your terminal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;gcloud app deploy
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We also need to change the &lt;code&gt;start&lt;/code&gt; script in our &lt;code&gt;package.json&lt;/code&gt;:&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="err"&gt;//&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;...&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="nl"&gt;"scripts"&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;"start"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"npm run serve:ssr"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="err"&gt;//&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;...&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="err"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="err"&gt;//&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;...&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And that's all, you should see your app running on Google Cloud! 👌&lt;/p&gt;

&lt;h3&gt;
  
  
  Using Firebase Cloud Functions
&lt;/h3&gt;

&lt;p&gt;In order to deploy our app using Firebase Cloud Functions we to need to init it and modify some files:&lt;/p&gt;

&lt;p&gt;To init Firebase run&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;firebase init
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and select &lt;code&gt;hosting&lt;/code&gt; and &lt;code&gt;functions&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Then modify your &lt;code&gt;funtions/package.json&lt;/code&gt; file:&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;"hosting"&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="err"&gt;//&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;...&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"rewrites"&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="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"source"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&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;"funtion"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"ssr"&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;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="err"&gt;//&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&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;Remove your express listener in &lt;code&gt;server.ts&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;// Start up the Node server&lt;/span&gt;
&lt;span class="c1"&gt;// app.listen(PORT, () =&amp;gt; {&lt;/span&gt;
&lt;span class="c1"&gt;//   console.log(`Node Express server listening on http://localhost:${PORT}`);&lt;/span&gt;
&lt;span class="c1"&gt;// })&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Update your &lt;code&gt;webpack.server.config.js&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;output&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// Puts the output at the root of the dist folder&lt;/span&gt;
  &lt;span class="nl"&gt;path&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;path&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;__dirname&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;dist&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
  &lt;span class="nx"&gt;library&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;app&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;libraryTarget&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;umd&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;filename&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;[name].js&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;},&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Make sure to rebuild your app running &lt;code&gt;npm run build:ssr&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;We then move in our &lt;code&gt;functions&lt;/code&gt; directory to install &lt;code&gt;fs-extra&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cd &lt;/span&gt;functions
npm &lt;span class="nb"&gt;install &lt;/span&gt;fs-extra &lt;span class="nt"&gt;--save&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The Firebase function needs to access our built app, so let's create a simple node script called &lt;code&gt;cp-angular,js&lt;/code&gt; that copies our app in the &lt;code&gt;functions&lt;/code&gt; folder:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;fs&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;fs-extra&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="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="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;src&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;../dist&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;copy&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./dist&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;fs&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="nx"&gt;copy&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;fs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;copy&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;src&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;copy&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="p"&gt;})();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then in our &lt;code&gt;functions/package.json&lt;/code&gt; we add a &lt;code&gt;build&lt;/code&gt; script:&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;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"functions"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"engines"&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;"node"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"10"&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;"scripts"&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;"build"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"node cp-angular &amp;amp;&amp;amp; tsc"&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;Then we can finally write our functions, so our &lt;code&gt;functions/index.js&lt;/code&gt; file will look something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nx"&gt;functions&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;firebase-functions&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;universal&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&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;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;cwd&lt;/span&gt;&lt;span class="p"&gt;()}&lt;/span&gt;&lt;span class="s2"&gt;/dist/server`&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;ssr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;functions&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;https&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;onRequest&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;universal&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To verify that all is working right you can use these commands:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cd &lt;/span&gt;functions
npm run build
firebase serve
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And if all looks good just deploy it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;firebase deploy
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Done! 😎
&lt;/h2&gt;

&lt;p&gt;That's all, you're now a master of Angular Universal!&lt;/p&gt;

</description>
      <category>angular</category>
      <category>ssr</category>
      <category>firebase</category>
      <category>nginx</category>
    </item>
    <item>
      <title>How I Built an Interactive Map from Scratch</title>
      <dc:creator>Michele Da Rin</dc:creator>
      <pubDate>Tue, 30 Jul 2019 15:33:27 +0000</pubDate>
      <link>https://dev.to/daudr/how-i-built-an-interactive-map-from-scratch-1kgf</link>
      <guid>https://dev.to/daudr/how-i-built-an-interactive-map-from-scratch-1kgf</guid>
      <description>&lt;p&gt;This article has been previously published on &lt;a href="https://blog.daudr.me/how-i-built-a-map"&gt;my main blog&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The other day I needed to complete a task for a client, this task consisted of creating an interactive map based on a static SVG. In this article, I'll explain how I accomplished the job 👌&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--U-Ziwn-o--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://images.unsplash.com/photo-1524661135-423995f22d0b%3Fixlib%3Drb-1.2.1%26ixid%3DeyJhcHBfaWQiOjEyMDd9%26auto%3Dformat%26fit%3Dcrop%26w%3D1953%26q%3D80" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--U-Ziwn-o--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://images.unsplash.com/photo-1524661135-423995f22d0b%3Fixlib%3Drb-1.2.1%26ixid%3DeyJhcHBfaWQiOjEyMDd9%26auto%3Dformat%26fit%3Dcrop%26w%3D1953%26q%3D80" alt="Build your map"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Photo by &lt;a href="https://unsplash.com/@drewmark"&gt;Andrew Stutesman&lt;/a&gt; on &lt;a href="https://unsplash.com/"&gt;Unsplash&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  First things first
&lt;/h2&gt;

&lt;p&gt;The problem was that the map used wasn't interactive at all, to show the selected regions you needed to add CSS classes, and there could be only one selected region at one time.&lt;br&gt;
So I searched the Internet for maybe one &lt;strong&gt;angular&lt;/strong&gt; library that could fit my needs, but, unfortunately, without results 😢&lt;/p&gt;
&lt;h2&gt;
  
  
  Let's create a new Angular lib
&lt;/h2&gt;

&lt;p&gt;So I said to myself: &lt;em&gt;Why not create a new library yourself?&lt;/em&gt; and that was it, I opened up my terminal and I typed&lt;/p&gt;

&lt;p&gt;&lt;code&gt;ng new lib @daudr/interactive-italy&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;(&lt;strong&gt;Yes, I started this project with only Italy in mind, but interchangeable maps are coming, stay tuned!&lt;/strong&gt; 😉)&lt;/p&gt;
&lt;h3&gt;
  
  
  Create the main component
&lt;/h3&gt;

&lt;p&gt;So I started creating the main component of the library, &lt;code&gt;interactive-italy.component.ts&lt;/code&gt;, but what's really is this component?&lt;br&gt;
The answer is simpler than you think, firstly I had to find the right SVG image, and being a noob in all of that I decided to look upon the Internet and I found just what I needed:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--1m3yIq5q--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://upload.wikimedia.org/wikipedia/commons/9/9b/Italy_map_with_regions.svg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--1m3yIq5q--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://upload.wikimedia.org/wikipedia/commons/9/9b/Italy_map_with_regions.svg" alt="Italy map with regions"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Thanks Wikimedia ❤&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The only problem was the map wasn't interactive.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;svg&lt;/span&gt;
  &lt;span class="na"&gt;width=&lt;/span&gt;&lt;span class="s"&gt;"460.30981"&lt;/span&gt;
  &lt;span class="na"&gt;height=&lt;/span&gt;&lt;span class="s"&gt;"562.58575"&lt;/span&gt;
&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;path&lt;/span&gt;
  &lt;span class="na"&gt;*ngFor=&lt;/span&gt;&lt;span class="s"&gt;"let region of regions"&lt;/span&gt;
  &lt;span class="na"&gt;[attr.d]=&lt;/span&gt;&lt;span class="s"&gt;"region.d"&lt;/span&gt;
  &lt;span class="na"&gt;[attr.title]=&lt;/span&gt;&lt;span class="s"&gt;"region.title"&lt;/span&gt;
  &lt;span class="na"&gt;(click)=&lt;/span&gt;&lt;span class="s"&gt;"onRegionClick(region.title)"&lt;/span&gt;
  &lt;span class="na"&gt;[ngClass]=&lt;/span&gt;&lt;span class="s"&gt;"{ selected: region.title | selected: selectedRegions }"&lt;/span&gt;
  &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/svg&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;It's all here, just that.&lt;/p&gt;

&lt;h3&gt;
  
  
  Create the data
&lt;/h3&gt;

&lt;p&gt;But let's find out what powers it:&lt;br&gt;
The &lt;code&gt;regions&lt;/code&gt; object represents an array that contains all the regions of the map as SVG's paths&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;REGIONS&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Region&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;d&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;m 374.27021,304.03051 1.36,6.34 2.24,5.51 6.27,11.18 7.01,7.71 8.24,6.15 0.87,2.33 3.67,3.53 0.33,1.35 5.56,3.7 5.16,1.83 0.21,4.85 3.43,2.43 0,0 -1.17,1.85 0.91,0.84 -2.84,1.96 -2.3,2.84 -0.82,3.1 -2.36,1.66 -1.72,3.73 -4.76,5.13 -2.04,-0.37 0.79,-0.64 -1.07,-4.29 -1.1,-1.07 -2.44,-1.62 -1.05,1.32 -0.57,-0.22 -0.98,-2.19 -1.24,0.13 -0.94,-1.26 -2.91,2.38 -1.43,2.22 -2.22,0.15 -0.42,0.9 1.25,3.55 1.52,0.89 -0.42,1.03 -0.85,-0.13 -0.25,-1.01 -0.67,1.24 -1.99,0.05 -0.63,2.64 -0.79,-2.07 -1.16,0.09 -0.87,2.4 -1.33,0.05 -0.28,1.46 -1.87,-0.98 -2.1,0.52 0,0 -2.49,-3.27 -1.96,0.19 -2.4,-1.41 -1.03,0.65 -1.33,-0.4 -1.75,-3.31 -1.32,0.73 -1.07,-1.18 -1.78,-0.49 -1.06,2.09 -4.05,1.35 -1.48,-0.93 -0.73,-1.81 -1.84,-0.43 -1.48,-1.43 -1.73,-0.7 -1.4,1.36 -1,-3.63 1.28,-2.29 -1,-1.41 -1.01,0.18 -1.98,-2.28 -0.9,0.37 -7.65,-4.49 -2.03,-0.72 -0.02,1.24 -2.38,-0.64 -1.41,-2.25 0.15,-4.92 0.78,0.36 2.08,-1.78 0.05,-2.39 1.73,-0.13 6.56,3.53 1.24,-0.77 1.69,0.62 1.07,-2.23 1.5,-0.29 -0.53,-0.71 1.83,-0.33 -1.93,-1.22 -0.3,-1.63 -2.43,-0.84 -2.58,-2.54 -0.65,-3.28 -3.74,-2.48 2.08,-2.33 -3.99,-3.74 3.18,-2.42 -0.1,-2.38 -1,-1.86 1.03,-0.58 0.76,-2.76 2.75,1.04 0.61,-0.73 1.35,0 0.58,0.98 1.5,-0.77 2.26,0.31 1.35,-1.17 0.76,-3.43 -1.99,-0.63 -1.15,-1.37 0.54,-1.68 0,0 0,0 0,0 0,0 0,0 1.66,0.48 1.88,-1.33 0.57,0.46 0.6,-2.37 2.37,-0.39 0.3,-2.49 1.34,-1.49 0.24,-1.44 2.08,1.13 2.37,-1.11 0.67,0.94 1.35,-0.17 2.01,-0.94 0.46,-2.21 0.68,-0.38 2.78,-0.18 2.11,-1.41 4.99,-1.07 0,0 z&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;title&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Abruzzo&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;d&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;m 457.43021,430.14051 -0.33,-1.23 1.34,-1.23 1.95,-0.38 4.65,0.78 2.51,-0.9 1.45,1.05 1.69,-0.91 -0.16,-0.95 1.67,-0.43 -0.18,-0.76 0.82,0.29 1.42,-0.85 2.3,1.65 1.74,0.3 0.24,1.03 1.26,0.3 0.61,2.35 0.62,-0.42 1.84,1.5 -0.64,1.04 0.3,1.55 -1.79,2.05 -1.51,-0.27 0.61,1.13 5.59,2.38 1.59,1.51 2.14,-1.96 2,0.65 2.94,6.46 6.56,6.05 0.78,1.74 1.53,0.42 3.48,-4.04 2.04,2.47 -0.06,-1.89 0.97,-0.26 0.85,1.33 0.11,-1.74 1.69,0.73 1.01,-0.64 0.17,0.99 1.17,0.7 0.54,-0.74 2.92,2.22 -1.03,0.51 1.22,1.41 -0.9,3.62 0.92,2.05 -0.63,0.46 -0.43,2.89 0.96,1.01 -0.44,0.81 1.16,0.88 -0.96,2.08 0.86,0.94 1.7,-0.43 1.77,1.07 0.37,1.62 1.74,1.47 0.78,1.86 0,0 -3.94,5.64 -4.81,10.36 -2.29,1.67 0,0 -2.72,-0.95 -3.12,0.97 -3.08,-1.02 -1.91,0.37 -0.66,-1.11 -0.63,1.47 0.22,2.84 -1.03,2.22 0.26,2 -3.05,5.44 1.11,1.14 -0.44,1.32 -2.14,-2.39 -2,-0.18 -2.93,0.66 -0.02,1.75 -2.78,-1.27 -1.04,1.08 -4.8,0.26 -1.55,-1.74 0.37,-0.62 -0.85,-1.6 1.24,-2.23 -1.16,-0.32 -1.49,0.85 -0.69,-0.96 -1.85,-0.3 -1.43,1.23 -0.62,-0.87 -0.93,0.49 -0.9,-0.94 -1.68,0.18 -2.35,2.53 -0.95,2.6 0,0 -1.79,-3.55 -2.1,-1.92 -0.14,-1.48 -1.68,-0.98 0,0 1.69,-1.01 -1.27,-1.38 1.21,-0.34 1.56,-2.12 -0.32,-2.91 1.62,-1.65 -0.14,-1 3.47,-1.48 -0.52,-1.23 0.93,-0.83 -0.04,-1.42 -0.61,-1.15 -2.93,-0.85 -0.14,-1.32 -1.64,-1.51 -0.05,-2.56 -2.1,-0.76 -1.6,-2.14 -2.06,-1.03 -0.48,-1.73 -2.17,-1.71 0.72,-1.08 -1.35,-3.21 0.7,-0.82 -4.35,-2.63 0.73,-2.02 1.65,-1.01 0.06,-0.81 -5.93,-3.85 0.17,-4.85 -0.82,-0.07 0.22,-1.18 -2.06,-1.27 2.1,-0.15 0.12,-2.14 -1.02,-0.52 0.43,-0.66 4.79,1.08 0.64,-0.35 -0.23,-1.16 2.96,-1.29 2.26,-5.87 z&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;title&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Basilicata&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="p"&gt;...&lt;/span&gt;
&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  And then comes the logic behind all
&lt;/h3&gt;

&lt;p&gt;If we add some logic we have our full component&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;InteractiveItalyComponent&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="nx"&gt;regions&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;REGIONS&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="nx"&gt;selectedRegions&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="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[];&lt;/span&gt;

  &lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;Output&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="nx"&gt;regionsChange&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;EventEmitter&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

  &lt;span class="nx"&gt;onRegionClick&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;region&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;index&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;selectedRegions&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;indexOf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;region&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nx"&gt;index&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;selectedRegions&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;region&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;selectedRegions&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;splice&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;index&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;regionsChange&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;emit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;selectedRegions&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;h3&gt;
  
  
  But don't forget the utilities
&lt;/h3&gt;

&lt;p&gt;I just added a pipe know if a region has been selected:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;SelectedPipe&lt;/span&gt; &lt;span class="k"&gt;implements&lt;/span&gt; &lt;span class="nx"&gt;PipeTransform&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;transform&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;value&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="nx"&gt;regions&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="nx"&gt;boolean&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;regions&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;indexOf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;And that's it! We built a fully interactive map of Italy just from an SVG image, isn't that cool? 😎&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--etYT7OEq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://firebasestorage.googleapis.com/v0/b/daudr-blog.appspot.com/o/interactive-map.gif%3Falt%3Dmedia%26token%3D330cb736-44a0-49a0-8c26-b13594471ff5" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--etYT7OEq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://firebasestorage.googleapis.com/v0/b/daudr-blog.appspot.com/o/interactive-map.gif%3Falt%3Dmedia%26token%3D330cb736-44a0-49a0-8c26-b13594471ff5" alt="The final result"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As a reminder I published this Angular library on NPM as Open Source, so check it out if you want!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.npmjs.com/package/@daudr/interactive-italy"&gt;@daudr/interactive-italy on NPM&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Also, let me know if you'd like to read how to publish an Angular library on NPM&lt;/em&gt;&lt;/p&gt;

</description>
      <category>angular</category>
      <category>code</category>
      <category>guide</category>
      <category>frontend</category>
    </item>
    <item>
      <title>ngFor Done Right</title>
      <dc:creator>Michele Da Rin</dc:creator>
      <pubDate>Thu, 04 Jul 2019 12:33:05 +0000</pubDate>
      <link>https://dev.to/daudr/ngfor-done-right-1ede</link>
      <guid>https://dev.to/daudr/ngfor-done-right-1ede</guid>
      <description>&lt;p&gt;&lt;strong&gt;This article has been previously published on my &lt;a href="https://blog.daudr.me/ngfor-done-right"&gt;main blog&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When dealing with lists in templates, ngFor saves us a lot of time, but it could be a real pain if used wrong, read this article to know hot use it right.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Srq1ie5g--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://images.unsplash.com/photo-1489976908522-aabacf277f49%3Fixlib%3Drb-1.2.1%26ixid%3DeyJhcHBfaWQiOjEyMDd9%26auto%3Dformat%26fit%3Dcrop%26w%3D1950%26q%3D80" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Srq1ie5g--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://images.unsplash.com/photo-1489976908522-aabacf277f49%3Fixlib%3Drb-1.2.1%26ixid%3DeyJhcHBfaWQiOjEyMDd9%26auto%3Dformat%26fit%3Dcrop%26w%3D1950%26q%3D80" alt="Arrive first with ngFor"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Photo by &lt;a href="https://unsplash.com/photos/ij5_qCBpIVY"&gt;Kolleen Gladden&lt;/a&gt; on &lt;a href="https://unsplash.com"&gt;Unsplash&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;All the information on this article can also be found in the official &lt;a href="https://angular.io/api/common/NgForOf"&gt;docs&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;p&gt;During this guide we will use an interface that represents our lists' object, let's call it &lt;code&gt;Item&lt;/code&gt;, that'll look something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kr"&gt;interface&lt;/span&gt; &lt;span class="nx"&gt;Item&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;_id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;
  &lt;span class="nx"&gt;name&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;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;and we will use some &lt;code&gt;utils&lt;/code&gt; mock and functions that'll help us later:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;items&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Item&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[{&lt;/span&gt; &lt;span class="na"&gt;_id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;a2fHdS8P&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Mike&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;}]&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;makeRandomId&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;():&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&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;characters&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="na"&gt;charactersLength&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;characters&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;
  &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;result&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="nx"&gt;characters&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;charAt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;floor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;random&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nx"&gt;charactersLength&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;result&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;makeRandomName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;():&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt; &lt;span class="o"&gt;=&amp;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;names&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Sara&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Mattia&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="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;names&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;floor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;random&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nx"&gt;names&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;itemsLong&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Item&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;_id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;makeRandomId&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
    &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;makeRandomName&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="na"&gt;_id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;makeRandomId&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
    &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;makeRandomName&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;h2&gt;
  
  
  First of all trackBy
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;trackBy&lt;/code&gt; is a function that defines how to track changes for items in the iterable. That means that we can use it to know exactly which element in a list are being changed, after a network call or whatsoever.&lt;br&gt;
We implement it by defining a function in our &lt;code&gt;.ts&lt;/code&gt; file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="nx"&gt;trackByFunction&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;index&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;_id&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;then in your &lt;code&gt;.html&lt;/code&gt; add your new function&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;*ngFor=&lt;/span&gt;&lt;span class="s"&gt;"let item of items; trackBy: trackByFunction"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Doing this lets your app be more performant as it doesn't need to reload all of your view but only the element that's being changed.&lt;/p&gt;

&lt;h2&gt;
  
  
  even and odd comes next
&lt;/h2&gt;

&lt;p&gt;The variables &lt;code&gt;even&lt;/code&gt; and &lt;code&gt;odd&lt;/code&gt; are mainly used for styling the components.&lt;br&gt;
For example, when we have a table and we want to make it more readable we can use these variables to change the background color of the rows.&lt;/p&gt;

&lt;p&gt;In your &lt;code&gt;html&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;table&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;thead&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;tr&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;th&amp;gt;&lt;/span&gt;ID&lt;span class="nt"&gt;&amp;lt;/th&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;th&amp;gt;&lt;/span&gt;Name&lt;span class="nt"&gt;&amp;lt;/th&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/tr&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/thead&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;tbody&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;tr&lt;/span&gt;
      &lt;span class="na"&gt;*ngFor=&lt;/span&gt;&lt;span class="s"&gt;"let item of items; trackBy: trackBy; odd as odd; even as even"&lt;/span&gt;
      &lt;span class="na"&gt;[ngClass]=&lt;/span&gt;&lt;span class="s"&gt;"{ 'odd': odd, 'even': even }"&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;td&amp;gt;&lt;/span&gt;{{ item._id }}&lt;span class="nt"&gt;&amp;lt;/td&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;td&amp;gt;&lt;/span&gt;{{ item.name }}&lt;span class="nt"&gt;&amp;lt;/td&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/tr&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/tbody&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/table&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;And in your &lt;code&gt;css&lt;/code&gt;/&lt;code&gt;scss&lt;/code&gt; file&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight scss"&gt;&lt;code&gt;&lt;span class="nc"&gt;.odd&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;rgba&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;255&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="m"&gt;255&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="mi"&gt;.45&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.even&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;rgba&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="mi"&gt;.45&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The result will be something like&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ku3RrCgF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/xw840y3l4ud1lqtz81f0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ku3RrCgF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/xw840y3l4ud1lqtz81f0.png" alt="Even and odd example"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Tell me about first and last
&lt;/h2&gt;

&lt;p&gt;Just like &lt;code&gt;even&lt;/code&gt; and &lt;code&gt;odd&lt;/code&gt;, &lt;code&gt;first&lt;/code&gt; and &lt;code&gt;last&lt;/code&gt; variables are used for styling purposes too.&lt;br&gt;
Let's use the already created table and set the classes only for the first and last row:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;table&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;thead&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;tr&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;th&amp;gt;&lt;/span&gt;ID&lt;span class="nt"&gt;&amp;lt;/th&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;th&amp;gt;&lt;/span&gt;Name&lt;span class="nt"&gt;&amp;lt;/th&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/tr&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/thead&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;tbody&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;tr&lt;/span&gt;
      &lt;span class="na"&gt;*ngFor=&lt;/span&gt;&lt;span class="s"&gt;"let item of items; trackBy: trackBy; first as first; last as last"&lt;/span&gt;
      &lt;span class="na"&gt;[ngClass]=&lt;/span&gt;&lt;span class="s"&gt;"{ 'first': first, 'last': last }"&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;td&amp;gt;&lt;/span&gt;{{ item._id }}&lt;span class="nt"&gt;&amp;lt;/td&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;td&amp;gt;&lt;/span&gt;{{ item.name }}&lt;span class="nt"&gt;&amp;lt;/td&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/tr&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/tbody&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/table&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;





&lt;div class="highlight"&gt;&lt;pre class="highlight scss"&gt;&lt;code&gt;&lt;span class="nc"&gt;.first&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;rgba&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="m"&gt;255&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="mi"&gt;.45&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.last&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;rgba&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="m"&gt;255&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="mi"&gt;.45&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;That'll look like this&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--dXKmLQSt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/t9tkh02ynxj1l1hmg2j0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--dXKmLQSt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/t9tkh02ynxj1l1hmg2j0.png" alt="First and last example"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Don't forget the index
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;index&lt;/code&gt; property does exactly what you think it does, it tells the index of the element in a list.&lt;br&gt;
Maybe it's the property that's being used the most when we are dealing with lists, just think if you want to lay your lists' element in defined rows using &lt;code&gt;css&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;mat-list&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;mat-list-item&lt;/span&gt; &lt;span class="na"&gt;*ngFor=&lt;/span&gt;&lt;span class="s"&gt;"let item of items; trackBy: trackByFunction; index as index"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;{{ item.name }} index is {{ index }}&lt;span class="nt"&gt;&amp;lt;/mat-list-item&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/mat-list&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0GQguHp4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/eruw3qir167islc8l5xv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0GQguHp4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/eruw3qir167islc8l5xv.png" alt="Index example"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;All the code used in this guide can be found on &lt;a href="https://stackblitz.com/edit/ngfor-done-right"&gt;Stackblitz&lt;/a&gt; and &lt;a href="https://github.com/Daudr/ngfor-done-right"&gt;GitHub&lt;/a&gt;&lt;/p&gt;

</description>
      <category>angular</category>
      <category>code</category>
      <category>frontend</category>
      <category>performance</category>
    </item>
    <item>
      <title>Write your first transaction on the Libra Network</title>
      <dc:creator>Michele Da Rin</dc:creator>
      <pubDate>Tue, 25 Jun 2019 08:02:21 +0000</pubDate>
      <link>https://dev.to/daudr/write-your-first-transaction-on-the-libra-network-5f5e</link>
      <guid>https://dev.to/daudr/write-your-first-transaction-on-the-libra-network-5f5e</guid>
      <description>&lt;p&gt;&lt;a href="https://blog.daudr.me/libra-simple-smart-contract" rel="noopener noreferrer"&gt;&lt;strong&gt;This article has been previously published on my main blog&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The other day I &lt;a href="https://blog.daudr.me/facebook-libra" rel="noopener noreferrer"&gt;published an article&lt;/a&gt; about the Libra Network, today we'll see how to build a transaction on it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fmw029rhi99hu6fh1dpcs.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%2Fmw029rhi99hu6fh1dpcs.png" alt="Libra logo"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Libra logo&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Installing the testnet locally
&lt;/h2&gt;

&lt;p&gt;Today we won't use &lt;a href="https://blog.daudr.me/facebook-libra" rel="noopener noreferrer"&gt;&lt;strong&gt;Move&lt;/strong&gt;&lt;/a&gt;, the new programming language created to build modules in the Libra Network, but only the terminal (at the moment the only OS supported are &lt;strong&gt;Linux&lt;/strong&gt; and &lt;strong&gt;macOS&lt;/strong&gt;).&lt;br&gt;
To install the &lt;code&gt;testnet&lt;/code&gt; you need some prerequisites:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;git&lt;/code&gt; installed on your machine;&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;Homebrew&lt;/code&gt; installed if you're using macOS&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Clone the Libra Core GitHub repository
&lt;/h2&gt;

&lt;p&gt;To install locally the &lt;code&gt;testnet&lt;/code&gt; just run this command on your terminal&lt;/p&gt;

&lt;p&gt;&lt;code&gt;git clone https://github.com/libra/libra.git&lt;/code&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Setup
&lt;/h2&gt;

&lt;p&gt;To setup Libra Core, go into the &lt;code&gt;libra&lt;/code&gt; directory and run the setup script to install the dependencies, run these commands on your &lt;code&gt;terminal&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd libra
./scripts/dev_setup.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The script simply does these things:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Installs &lt;code&gt;rustup&lt;/code&gt; -  &lt;code&gt;rustup&lt;/code&gt; is an installer for the Rust programming language, which &lt;code&gt;Libra Core&lt;/code&gt; is implemented in.&lt;/li&gt;
&lt;li&gt;Installs the required versions of the &lt;code&gt;rust-toolchain&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Installs &lt;code&gt;CMake&lt;/code&gt;  - to manage the build process.&lt;/li&gt;
&lt;li&gt;Installs &lt;code&gt;protoc&lt;/code&gt; - a compiler for protocol buffers.&lt;/li&gt;
&lt;li&gt;Installs &lt;code&gt;Go&lt;/code&gt; - for building protocol buffers.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Troubleshoot
&lt;/h2&gt;

&lt;p&gt;If the setup fails, try to run these others commands:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Update &lt;code&gt;Rust&lt;/code&gt;:&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;  Run &lt;code&gt;rustup&lt;/code&gt; update from your libra directory.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Re-run setup script from your libra directory:&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;./scripts/dev_setup.sh&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Build Libra CLI Client and Connect to the Testnet
&lt;/h2&gt;

&lt;p&gt;To connect to a validator node running on the Libra &lt;code&gt;testnet&lt;/code&gt; run the command:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;./scripts/cli/start_cli_testnet.sh&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This command builds and runs the client utilizing &lt;code&gt;cargo&lt;/code&gt; (&lt;code&gt;Rust&lt;/code&gt;'s package manager) and connects the client to a validator node on the &lt;code&gt;testnet&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Once the client connects to a node on the &lt;code&gt;testnet&lt;/code&gt;, you will see the following output. To quit the client at any time, use the &lt;code&gt;quit&lt;/code&gt; command.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;usage: &amp;lt;command&amp;gt; &amp;lt;args&amp;gt; 
Use the following commands: 
account | a   Account operations
query | q   Query operations
transfer | transferb | t | tb
  &amp;lt;sender_account_address&amp;gt;|&amp;lt;sender_account_ref_id&amp;gt;
  &amp;lt;receiver_account_address&amp;gt;|&amp;lt;receiver_account_ref_id&amp;gt;
  &amp;lt;number_of_coins&amp;gt; [gas_unit_price (default=0)]
  [max_gas_amount (default 10000)] Suffix 'b' is for blocking.  
  Transfer coins from account to another.
help | h   Prints this help
quit | q!   Exit this client
Please, input commands:
libra%
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Troubleshoot
&lt;/h2&gt;

&lt;p&gt;If you are experiencing build failures, try to remove the &lt;code&gt;cargo lock&lt;/code&gt; file from the libra directory:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;rm Cargo.lock&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;If your client did not connect to the testnet:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Check your internet connection.&lt;/li&gt;
&lt;li&gt;Ensure that you are using the latest version of the client. Pull the latest Libra Core and rerun the client:&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;./scripts/cli/start_cli_testnet.sh&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Create new accounts
&lt;/h2&gt;

&lt;p&gt;Once your client is connected to the &lt;code&gt;testnet&lt;/code&gt;, you can run CLI commands to create new accounts. I'll walk you through creating accounts for two users.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: Check if the client is running
&lt;/h3&gt;

&lt;p&gt;A libra% command line prompt indicates that your Libra CLI client is running. To see the help information for the &lt;code&gt;account&lt;/code&gt; command enter "account" as shown below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;libra% account
usage: account &amp;lt;arg&amp;gt;
Use the following args for this command:
create | c   Create an account. Returns reference ID to use in other operations
list | la   Print all accounts that were created or loaded
recover | r &amp;lt;file path&amp;gt;   Recover Libra wallet from the file path
write | w &amp;lt;file name&amp;gt;   Save Libra wallet mnemonic recovery seed to disk
mint | mintb | m | mb &amp;lt;receiver account&amp;gt; &amp;lt;number of coins&amp;gt;   Mint coins to the account. Suffix 'b' is for blocking
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 2: create the first account
&lt;/h3&gt;

&lt;p&gt;Note that creating an account using the CLI does not update the &lt;code&gt;blockchain&lt;/code&gt;, it just creates a local key-pair.&lt;br&gt;
To create the first account, enter this command:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;libra% account create&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This command will generate an output like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt; Creating/retrieving next account from wallet
Created/retrieved account #0 address 1h3n34fafae4147b2a105a0be2f91238adcfaaadf93fc0868e7a0253c4a8
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;#0 is the index of the account, and the hex string is the address of the account. The index is just a way to refer to the account. The account index is a local CLI index that can be used in other CLI commands for users to conveniently refer to the accounts they have created. The index is meaningless to the blockchain. The account will be created on the blockchain only when either money is added to the account via minting, or money is transferred to the account via a transfer from another user. Note that you may also use the hex address in CLI commands. The account index is just a convenience wrapper around the account address.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 3: create the second account
&lt;/h3&gt;

&lt;p&gt;To create the second account, repeat the account creation command:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;libra% account create&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  [Optional] Step 4: list accounts
&lt;/h3&gt;

&lt;p&gt;To list the accounts you have created, enter this command:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;libra% account list&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This is what you'll see:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;User account index: 0, address: 3ed8e5fafae4147b2a105a0be2f81972883441cfaaadf93fc0868e7a0253c4a8, sequence number: 0
User account index: 1, address: 8337aac709a41fe6be03cad8878a0d4209740b1608f8a81566c9a7d4b95a2ec7, sequence number: 0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The sequence number for an account indicates the number of transactions that have been sent from that account. It is incremented every time a transaction sent from that account is executed and stored in the blockchain.&lt;/p&gt;

&lt;h2&gt;
  
  
  Add Libra Coins to the accounts
&lt;/h2&gt;

&lt;p&gt;Minting and adding coins to accounts on &lt;code&gt;testnet&lt;/code&gt; is done via &lt;code&gt;faucet&lt;/code&gt;. &lt;code&gt;Faucet&lt;/code&gt; is a service that runs along with the &lt;code&gt;testnet&lt;/code&gt;. This service only exists to facilitate minting coins for &lt;code&gt;testnet&lt;/code&gt; and will not exist for &lt;code&gt;mainnet&lt;/code&gt;. It creates Libra with no real-world value. Assuming you have created two accounts, with index 0 and index 1 respectively, you can follow the steps below to add Libra to both accounts.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: Add Libra Coins to the accounts
&lt;/h3&gt;

&lt;p&gt;To mint Libra and add to the first account, enter this command:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;libra% account mint 0 125&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;0 is the index of the account.&lt;/li&gt;
&lt;li&gt;125 is the amount of Libra to be added to the account.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A successful &lt;code&gt;account mint&lt;/code&gt; command will also create the account on the &lt;code&gt;blockchain&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Sample output on success:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt; Minting coins
Mint request submitted
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note that when the request is submitted, it means that it has been added to the &lt;code&gt;mempool&lt;/code&gt; (of a validator node on &lt;code&gt;testnet&lt;/code&gt;) successfully. It does not necessarily imply that it will be successfully completed. Later, we will query the account balance to confirm if minting was successful.&lt;/p&gt;

&lt;p&gt;To mint Libra and add to the second account, enter this command:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;libra% account mint 1 50&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;1 is the index of the account.&lt;/li&gt;
&lt;li&gt;50 is the amount of Libra to be added to the account.&lt;/li&gt;
&lt;li&gt;A successful account mint command will also create the account on the blockchain. Another way to create an account on the blockchain is to transfer money from the any other account.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Step 3: Check an accounts' balance
&lt;/h3&gt;

&lt;p&gt;To check the balance in the first account, enter this command:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;libra% query balance 0&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Sample output on success:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Balance is 100&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Submit a transaction
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;libra% query sequence 0
&amp;gt;&amp;gt; Getting current sequence number Sequence number is: 0
libra% query sequence 1
&amp;gt;&amp;gt; Getting current sequence number Sequence number is: 0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In &lt;code&gt;query sequence 0&lt;/code&gt;, 0 is the index of the first account. A sequence number of 0 for both the accounts indicates that no transactions from either one of the accounts have been executed so far.&lt;/p&gt;

&lt;h2&gt;
  
  
  Transfer money
&lt;/h2&gt;

&lt;p&gt;To submit a transaction to transfer 10 Libra from the first account to the second, enter this command:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;libra% transfer 0 1 10&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;0 is the index of the first account.&lt;/li&gt;
&lt;li&gt;1 is the index of the second account.&lt;/li&gt;
&lt;li&gt;10 is the number of Libra to transfer from the first account to the other account.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This will generate:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt; Transferring
Transaction submitted to validator
To query for transaction status, run: query txn_acc_seq 0 0 &amp;lt;fetch_events=true|false&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can use the command &lt;code&gt;query txn_acc_seq 0 0 true&lt;/code&gt; (transaction by account and sequence number) to retrieve the information about the transaction you just submitted. The first parameter is the local index of the sender account, and the second parameter is the sequence number of the account.&lt;/p&gt;

&lt;p&gt;You just submitted your transaction to a validator node on &lt;code&gt;testnet&lt;/code&gt;, and it was included in the &lt;code&gt;mempool&lt;/code&gt; of the validator. This doesn't necessarily mean your transaction has been executed. In theory, if the system were slow or overloaded, it would take some time to see the results, and you may have to check multiple times by querying the accounts. To query an account with index 0, you can use the command &lt;code&gt;query account_state 0&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Blocking Transfer Command&lt;/strong&gt;: You can use the &lt;code&gt;transferb&lt;/code&gt; command (as shown below), instead of the &lt;code&gt;transfer&lt;/code&gt; command. &lt;code&gt;transferb&lt;/code&gt; will submit the transaction and return to the client prompt only after the transaction has been committed to the blockchain.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;libra% transferb 0 1 10&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Query sequence number after transfer
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;libra% query sequence 0
&amp;gt;&amp;gt; Getting current sequence number Sequence number is: 1
libra% query sequence 1
&amp;gt;&amp;gt; Getting current sequence number Sequence number is: 0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The sequence number of 1 for the first account (index 0) indicates that one transaction has been sent from that account so far. The sequence number of 0 for the second account (index 1) indicates that no transaction has been sent from that account so far. Every time a transaction is sent from an account, the sequence number is incremented by 1.&lt;/p&gt;

&lt;h2&gt;
  
  
  Check the accounts' balance after the transfer
&lt;/h2&gt;

&lt;p&gt;To check the final balance in both accounts, query the balance again for each account as you did in this step. If your transaction (&lt;code&gt;transfer&lt;/code&gt;) executed successfully, you should see 90 Libra in the first account and 60 Libra in the second account.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;libra% query balance 0
Balance is: 90
libra% query balance 1
Balance is: 60
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Congratulations!
&lt;/h2&gt;

&lt;p&gt;You have successfully executed your transaction on the Libra &lt;code&gt;testnet&lt;/code&gt; and transferred 10 &lt;strong&gt;Libra Coins&lt;/strong&gt;!&lt;/p&gt;

</description>
      <category>facebook</category>
      <category>libra</category>
      <category>blockchain</category>
      <category>cryptocurrency</category>
    </item>
    <item>
      <title>The new Facebook cryptocurrency: Libra</title>
      <dc:creator>Michele Da Rin</dc:creator>
      <pubDate>Thu, 20 Jun 2019 08:41:28 +0000</pubDate>
      <link>https://dev.to/daudr/the-new-facebook-cryptocurrency-libra-g8e</link>
      <guid>https://dev.to/daudr/the-new-facebook-cryptocurrency-libra-g8e</guid>
      <description>&lt;p&gt;&lt;strong&gt;&lt;a href="https://blog.daudr.me/facebook-libra" rel="noopener noreferrer"&gt;This article was previously published on my main blog.&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Recently Mark Zuckerberg has announced Facebook's new cryptocurrency called Libra, let's see what it is.&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%2Fimages.unsplash.com%2Fphoto-1555020368-9e1b4cf78a52%3Fixlib%3Drb-1.2.1%26auto%3Dformat%26fit%3Dcrop%26w%3D1136%26q%3D80" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimages.unsplash.com%2Fphoto-1555020368-9e1b4cf78a52%3Fixlib%3Drb-1.2.1%26auto%3Dformat%26fit%3Dcrop%26w%3D1136%26q%3D80" alt="What's on your mind?"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Photo by &lt;a href="https://unsplash.com/photos/Uo2ZXh4XOLY" rel="noopener noreferrer"&gt;Joshua Hoehne&lt;/a&gt; on &lt;a href="https://unsplash.com" rel="noopener noreferrer"&gt;Unsplash&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Libra, the new Facebook cryptocurrency
&lt;/h2&gt;

&lt;p&gt;The mission of Libra is simple and clear:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;A simple global currency and financial infrastructure that empowers billions of people.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Libra is a stable coin, meaning that, unlike Bitcoin, it doesn't have the volatility but has a reserve backed by real assets that maintain stable its value.&lt;br&gt;
With Libra, Facebook is creating also an association, The Libra Association, with the purpose of regulating the growth of Libra itself. These are the 27 founding members:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Payments: &lt;em&gt;Mastercard&lt;/em&gt;, &lt;em&gt;PayPal&lt;/em&gt;, &lt;em&gt;PayU (Naspers' fintech arm)&lt;/em&gt;, &lt;em&gt;Stripe&lt;/em&gt;, &lt;em&gt;Visa&lt;/em&gt;&lt;br&gt;&lt;br&gt;
Technology and marketplaces: &lt;em&gt;Booking Holdings&lt;/em&gt;, &lt;em&gt;eBay&lt;/em&gt;, &lt;em&gt;Facebook/Calibra&lt;/em&gt;, &lt;em&gt;Farfetch&lt;/em&gt;, &lt;em&gt;Lyft&lt;/em&gt;, &lt;em&gt;MercadoPago&lt;/em&gt;, &lt;em&gt;Spotify AB&lt;/em&gt;, &lt;em&gt;Uber Technologies, Inc.&lt;/em&gt;&lt;br&gt;&lt;br&gt;
Telecommunications: &lt;em&gt;Iliad&lt;/em&gt;, &lt;em&gt;Vodafone Group&lt;/em&gt;&lt;br&gt;&lt;br&gt;
Blockchain: &lt;em&gt;Anchorage&lt;/em&gt;, &lt;em&gt;Bison Trails&lt;/em&gt;, &lt;em&gt;Coinbase, Inc.&lt;/em&gt;, &lt;em&gt;Xapo Holdings Limited&lt;/em&gt;&lt;br&gt;&lt;br&gt;
Venture Capital: &lt;em&gt;Andreessen Horowitz&lt;/em&gt;, &lt;em&gt;Breakthrough Initiatives&lt;/em&gt;, &lt;em&gt;Ribbit Capital&lt;/em&gt;, &lt;em&gt;Thrive Capital&lt;/em&gt;, &lt;em&gt;Union Square Ventures&lt;/em&gt;&lt;br&gt;&lt;br&gt;
Nonprofit and multilateral organizations, and academic institutions: &lt;em&gt;Creative Destruction Lab&lt;/em&gt;, &lt;em&gt;Kiva&lt;/em&gt;, &lt;em&gt;Mercy Corps&lt;/em&gt;, &lt;em&gt;Women's World Banking&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Facebook will try to extend this list to a total of 100 members before Libra's release, planned in the middle of 2020.&lt;/p&gt;
&lt;h2&gt;
  
  
  How do I start with the Libra Network
&lt;/h2&gt;

&lt;p&gt;The Libra Network is based on smart contracts, like Ethereum and uses a Byzantine Fault Tolerant (BFT) proof of stake, the one that NEO &lt;a href="https://docs.neo.org/it-it/node/whitepaper.html" rel="noopener noreferrer"&gt;uses&lt;/a&gt;.&lt;br&gt;
&lt;a href="https://blog.daudr.me/libra-simple-smart-contract" rel="noopener noreferrer"&gt;Here&lt;/a&gt; you will find a simple guide that illustrates how to start your local testnet and familiarise with the Libra Network.&lt;/p&gt;
&lt;h2&gt;
  
  
  The Move programming language
&lt;/h2&gt;

&lt;p&gt;Alongside Libra a new programming language will be released: Move.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;This programming language will let developers implement custom "smart contracts" for this new ecosystem.&lt;br&gt;&lt;br&gt;
There are two important building blocks that will appear in almost any transaction script: the LibraAccount.T and LibraCoin.T resource types. LibraAccount is the name of the module, and T is the name of a resource declared by that module. This is a common naming convention in Move; the "main" type declared by a module is typically named T.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This is an example from the &lt;a href="https://developers.libra.org/docs/move-overview#writing-transaction-scripts" rel="noopener noreferrer"&gt;Move website&lt;/a&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Simple peer-peer payment example.&lt;/span&gt;

&lt;span class="c1"&gt;// Use LibraAccount module published on the blockchain at account address&lt;/span&gt;
&lt;span class="c1"&gt;// 0x0...0 (with 64 zeroes). 0x0 is shorthand that the IR pads out to&lt;/span&gt;
&lt;span class="c1"&gt;// 256 bits (64 digits) by adding leading zeroes.&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="mh"&gt;0x0&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;LibraAccount&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="mh"&gt;0x0&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;LibraCoin&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;payee&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;address&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;amount&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;u64&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// The bytecode (and consequently, the IR) has typed locals.  The scope of&lt;/span&gt;
  &lt;span class="c1"&gt;// each local is the entire procedure. All local variable declarations must&lt;/span&gt;
  &lt;span class="c1"&gt;// be at the beginning of the procedure. Declaration and initialization of&lt;/span&gt;
  &lt;span class="c1"&gt;// variables are separate operations, but the bytecode verifier will prevent&lt;/span&gt;
  &lt;span class="c1"&gt;// any attempt to use an uninitialized variable.&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;coin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;R&lt;/span&gt;&lt;span class="err"&gt;#&lt;/span&gt;&lt;span class="nx"&gt;LibraCoin&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;T&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="c1"&gt;// The R# part of the type above is one of two *kind annotation* R# and V#&lt;/span&gt;
  &lt;span class="c1"&gt;// (shorthand for "Resource" and "unrestricted Value"). These annotations&lt;/span&gt;
  &lt;span class="c1"&gt;// must match the kind of the type declaration (e.g., does the LibraCoin&lt;/span&gt;
  &lt;span class="c1"&gt;// module declare `resource T` or `struct T`?).&lt;/span&gt;

  &lt;span class="c1"&gt;// Acquire a LibraCoin.T resource with value `amount` from the sender's&lt;/span&gt;
  &lt;span class="c1"&gt;// account.  This will fail if the sender's balance is less than `amount`.&lt;/span&gt;
  &lt;span class="nx"&gt;coin&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;LibraAccount&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;withdraw_from_sender&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;move&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;amount&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
  &lt;span class="c1"&gt;// Move the LibraCoin.T resource into the account of `payee`. If there is no&lt;/span&gt;
  &lt;span class="c1"&gt;// account at the address `payee`, this step will fail&lt;/span&gt;
  &lt;span class="nx"&gt;LibraAccount&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;deposit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;move&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;payee&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="nf"&gt;move&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;coin&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;

  &lt;span class="c1"&gt;// Every procedure must end in a `return`. The IR compiler is very literal:&lt;/span&gt;
  &lt;span class="c1"&gt;// it directly translates the source it is given. It will not do fancy&lt;/span&gt;
  &lt;span class="c1"&gt;// things like inserting missing `return`s.&lt;/span&gt;
  &lt;span class="k"&gt;return&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;h2&gt;
  
  
  The Libra Association
&lt;/h2&gt;

&lt;p&gt;The Libra Association will be based in Geneva, Switzerland (considered by Libra founding members a neutral state, the ideal for this new "neutral" stable coin).&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The Libra Association is an independent, Swiss not-for-profit organization with the mission to empower billions of people through the creation of a simple global currency and financial infrastructure. The association membership is made up of the validator nodes of the Libra network. Initially, these are global companies, social impact partners (SIPs), and academic institutions — the Libra Association's Founding Members. Eventually, the association will include any entity that operates a validator node and holds sufficient stake in Libra.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Calibra: The Libra wallet
&lt;/h2&gt;

&lt;p&gt;Facebook is also creating a wallet for Libra, called Calibra.&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%2Ffbnewsroomus.files.wordpress.com%2F2019%2F06%2Fcalibraapp_earlylook_en402x.png%3Fw%3D1024%26h%3D576" 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%2Ffbnewsroomus.files.wordpress.com%2F2019%2F06%2Fcalibraapp_earlylook_en402x.png%3Fw%3D1024%26h%3D576" alt="Calibra early stage"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Calibra is a&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Facebook subsidiary whose goal is to provide financial services that will let people access and participate in the Libra Network&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Calibra is still in its early development stage, its release is planned in 2020, so the real experience can change a lot from now on, but as we can read from the &lt;a href="https://newsroom.fb.com/news/2019/06/coming-in-2020-calibra/" rel="noopener noreferrer"&gt;Facebook announcement&lt;/a&gt;:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;From the beginning, Calibra will let you send Libra to almost anyone with a smartphone, as easily and instantly as you might send a text message and at low to no cost. And, in time, we hope to offer additional services for people and businesses, like paying bills with the push of a button, buying a cup of coffee with the scan of a code or riding your local public transit without needing to carry cash or a metro pass&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>facebook</category>
      <category>libra</category>
      <category>blockchain</category>
      <category>cryptocurrency</category>
    </item>
    <item>
      <title>Conditional Polyfill in Angular v7</title>
      <dc:creator>Michele Da Rin</dc:creator>
      <pubDate>Mon, 20 May 2019 12:46:41 +0000</pubDate>
      <link>https://dev.to/daudr/conditional-polyfill-in-angular-v7-knk</link>
      <guid>https://dev.to/daudr/conditional-polyfill-in-angular-v7-knk</guid>
      <description>&lt;p&gt;This article was previously published on &lt;a href="https://blod.daudr.me/conditional-polyfills"&gt;my main blog&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;If you have a project that's based on Angular v7 and don't have the chance to upgrade to the upcoming v8 or you want to test one of the most useful small features of the future version here you will find how to do it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ArPYyuce--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://images.unsplash.com/photo-1511715282680-fbf93a50e721%3Fixlib%3Drb-1.2.1%26ixid%3DeyJhcHBfaWQiOjEyMDd9%26auto%3Dformat%26fit%3Dcrop%26w%3D1950%26q%3D80" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ArPYyuce--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://images.unsplash.com/photo-1511715282680-fbf93a50e721%3Fixlib%3Drb-1.2.1%26ixid%3DeyJhcHBfaWQiOjEyMDd9%26auto%3Dformat%26fit%3Dcrop%26w%3D1950%26q%3D80" alt="Dance of souls"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Photo by &lt;a href="https://unsplash.com/photos/JhqhGfX_Wd8"&gt;Ahmad Odeh&lt;/a&gt; on &lt;a href="https://unsplash.com"&gt;Unsplash&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  The trick
&lt;/h2&gt;

&lt;p&gt;In the development of Angular, we’re using TypeScript with a lot of modern JavaScript features. Not all of them are supported by the users’ browsers so that’s why as part of the production build we ship a file called polyfills.js.&lt;/p&gt;

&lt;p&gt;Over the past couple of years, browsers started implementing a lot of these APIs. The chances are that a user who’s on the latest version of Chrome, for instance, will not need any of the ES2015 polyfills that we ship as part of polyfills.js. Instead, their browser will support them natively. This makes large portion of the content of polyfills.js obsolete and unnecessary.&lt;/p&gt;

&lt;p&gt;That’s why, starting from Angular CLI 7.3.0, it was introduced conditional polyfill loading! As part of the default build process, Angular CLI will produce two bundles polyfills.js and es2015-polyfills.js. polyfills.js includes only the polyfills required by the browsers which have all the ES2015 features implemented natively. In contrast, es2015-polyfills.js contains all the polyfills from polyfills.js + ES2015 ones (such as Map, Set, etc).&lt;/p&gt;

&lt;p&gt;The result should be your &lt;code&gt;index.html&lt;/code&gt;'s body looking like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;body&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;app-root&amp;gt;&amp;lt;/app-root&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"text/javascript"&lt;/span&gt; &lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"runtime.***.js"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"text/javascript"&lt;/span&gt; &lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"es2015-polyfills.***.js"&lt;/span&gt; &lt;span class="na"&gt;nomodule&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"text/javascript"&lt;/span&gt; &lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"polyfills.***.js"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"text/javascript"&lt;/span&gt; &lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"main.***.js"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;On the snippet above, you can see that Angular CLI has added the &lt;code&gt;nomodule&lt;/code&gt; attribute to the es2015 polyfills tag. This attribute let the browsers download and execute the script only if it doesn't recognize the &lt;a href="https://html.spec.whatwg.org/multipage/webappapis.html#module-script"&gt;module script web api&lt;/a&gt;, this means that the browser is old 👌&lt;/p&gt;

&lt;p&gt;You might be wondering: all my users are with modern browsers, why would I have to wait for the CLI to produce es2015-polyfills.js that will never be in use? If you’re really thinking this, then you’re a happy developer. If you want to ignore ES2015 polyfills completely, then build your application running:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;ng build --es5BrowserSupport=false&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;By setting the --es5BrowserSupport flag to false, Angular CLI will produce only polyfills.js which contains the polyfills required by ES2015 enabled browsers, but your app won't work properly on those old browsers anymore.&lt;/p&gt;

&lt;p&gt;If you don't want to set the property every time you run the build command, you can directly modify the property in your &lt;code&gt;angular.json&lt;/code&gt; file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="nl"&gt;"projects"&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;"project-name"&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="err"&gt;...&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"architect"&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;"build"&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="err"&gt;...&lt;/span&gt;&lt;span class="w"&gt;
          &lt;/span&gt;&lt;span class="nl"&gt;"options"&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="err"&gt;...&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"es5BrowserSupport"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;false&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;This trick lets you save the scripting of about 60Kb of javascript 😎&lt;/p&gt;

</description>
      <category>angular</category>
      <category>polyfills</category>
      <category>performance</category>
      <category>web</category>
    </item>
  </channel>
</rss>
