<?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: ~AlleAmiDev~</title>
    <description>The latest articles on DEV Community by ~AlleAmiDev~ (@alleamitrano).</description>
    <link>https://dev.to/alleamitrano</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%2F338358%2F559a9c8c-d37b-4e98-b380-edfa4ea9a39c.jpg</url>
      <title>DEV Community: ~AlleAmiDev~</title>
      <link>https://dev.to/alleamitrano</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/alleamitrano"/>
    <language>en</language>
    <item>
      <title>Display Colorful Tweets in Your Angular App</title>
      <dc:creator>~AlleAmiDev~</dc:creator>
      <pubDate>Wed, 18 Mar 2020 16:06:56 +0000</pubDate>
      <link>https://dev.to/alleamitrano/display-colorful-tweets-in-your-angular-app-eoa</link>
      <guid>https://dev.to/alleamitrano/display-colorful-tweets-in-your-angular-app-eoa</guid>
      <description>&lt;p&gt;A simple library to color #hashtags and @mentions in your posts&lt;/p&gt;

&lt;p&gt;It’s very common for front-end developers to work on social feed functionalities.&lt;br&gt;
In many cases, it is possible to use embedded code or widgets to display recent tweets or posts, but sometimes clients might require a custom interface. That’s what happened to me this week.&lt;/p&gt;



&lt;h2&gt;
  
  
  The Problem
&lt;/h2&gt;

&lt;p&gt;I had to work on an animated Twitter feed and I was requested to assign a specific color to hashtags and mentions in the text.&lt;br&gt;
However, as the whole tweet comes from the API as a string, I had to come up with a functional way of processing the text to extract words starting with # and @ and give them a different color from the rest of the text.&lt;br&gt;
So, I created a small library!&lt;/p&gt;



&lt;h2&gt;
  
  
  Introducing Hashtag-Mention-Colorizer
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://www.npmjs.com/package/hashtag-mention-colorizer"&gt;Hashtag-Mention-Colorizer&lt;/a&gt; is a small library that exposes an Angular pipe. You can use it to find hashtags and mentions in your strings and color them by passing the color code as a parameter for the pipe.&lt;br&gt;
You can install it with the command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm i hashtag-mention-colorizer
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;And then include it in your preferred module:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;HashtagMentionColLibModule&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;dist/hashtag-mention-col-lib&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;BrowserModule&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/platform-browser&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;NgModule&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;AppComponent&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;./app.component&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;NgModule&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;declarations&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;AppComponent&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
  &lt;span class="na"&gt;imports&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;BrowserModule&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;HashtagMentionColLibModule&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
  &lt;span class="na"&gt;providers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[],&lt;/span&gt;
  &lt;span class="na"&gt;bootstrap&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;AppComponent&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="nx"&gt;AppModule&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Now the hmcolor pipe will be ready to use in the app templates.&lt;/p&gt;



&lt;h2&gt;
  
  
  A Quick Example
&lt;/h2&gt;

&lt;p&gt;So, let’s say we want to find all the hashtags and mentions in this text:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;Component&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="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="nx"&gt;AppComponent&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;text1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Hello! @AlessiaAmitrano here! Check out my amazing new #angular #library ! &lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nx"&gt;text2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;#frontend @devLifeUk #developer &lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;We can use the pipe to achieve this!&lt;/p&gt;

&lt;p&gt;If we don’t pass a specific color to it, it will apply a standard light blue color to all the hashtags and mentions in the text. We can try it out by using this template:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"container"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;article&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"card"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"header"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;img&lt;/span&gt; &lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"assets/me.png"&lt;/span&gt; &lt;span class="na"&gt;alt=&lt;/span&gt;&lt;span class="s"&gt;""&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"header-text"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;span&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"name"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;~AlleAmiDev~&lt;span class="nt"&gt;&amp;lt;/span&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;span&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"nickname"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;@AlessiaAmitrano&lt;span class="nt"&gt;&amp;lt;/span&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;span&lt;/span&gt; &lt;span class="na"&gt;[innerHTML]=&lt;/span&gt;&lt;span class="s"&gt;"text1 | hmColor"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/span&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;span&lt;/span&gt; &lt;span class="na"&gt;[innerHTML]=&lt;/span&gt;&lt;span class="s"&gt;"text2 | hmColor: '#18BE63'"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/span&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/article&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;As you can see, for text1, I use the pipe without declaring a custom color. On the contrary, with text2, I specify I want to apply the color ‘#18BE63’.&lt;br&gt;
Attention: The pipe only works by passing the processed string to an HTML element through the [innerHtml] property.&lt;br&gt;
The result will be the one in the cover image!&lt;/p&gt;

&lt;p&gt;Et voilà! You can check out the complete code in the library’s &lt;a href="https://github.com/alessiaAmitrano/hashtag-mention-colorizer"&gt;GitHub repo&lt;/a&gt;.&lt;/p&gt;




&lt;p&gt;Originally published on Medium.&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag__link"&gt;
  &lt;a href="https://medium.com/better-programming/how-to-display-colorful-tweets-in-your-angular-app-4ee61ff59125" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__pic"&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Ix95KlMx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://miro.medium.com/fit/c/96/96/2%2AkT8x7Mj4nI8vbc_2MJZyQQ.jpeg" alt="Alessia Amitrano"&gt;
    &lt;/div&gt;
  &lt;/a&gt;
  &lt;a href="https://medium.com/better-programming/how-to-display-colorful-tweets-in-your-angular-app-4ee61ff59125" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__content"&gt;
      &lt;h2&gt;How to Display Colorful Tweets in Your Angular App | by Alessia Amitrano | Better Programming&lt;/h2&gt;
      &lt;h3&gt;Alessia Amitrano ・ &lt;time&gt;Mar 17, 2020&lt;/time&gt; ・ 
      &lt;div class="ltag__link__servicename"&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ze5yh_2q--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/medium_icon-90d5232a5da2369849f285fa499c8005e750a788fdbf34f5844d5f2201aae736.svg" alt="Medium Logo"&gt;
        Medium
      &lt;/div&gt;
    &lt;/h3&gt;
&lt;/div&gt;
  &lt;/a&gt;
&lt;/div&gt;



</description>
      <category>angular</category>
      <category>javascript</category>
      <category>typescript</category>
      <category>programming</category>
    </item>
    <item>
      <title>How I Got Rid of State Observables in Angular</title>
      <dc:creator>~AlleAmiDev~</dc:creator>
      <pubDate>Tue, 25 Feb 2020 17:43:29 +0000</pubDate>
      <link>https://dev.to/alleamitrano/how-i-got-rid-of-state-observables-in-angular-4343</link>
      <guid>https://dev.to/alleamitrano/how-i-got-rid-of-state-observables-in-angular-4343</guid>
      <description>&lt;p&gt;When developing a complex SPA in Angular, using a state management library makes things so much easier.&lt;/p&gt;

&lt;p&gt;The app store acts as a single source of truth and contains all the data that is fundamental to the correct functioning of the app. Thanks to the store, I can access or edit this data from any smart component (or container).&lt;/p&gt;

&lt;p&gt;However, it can be frustrating to deal with all the subscriptions to the store; many times I have to deal with multiple @Select() in a single component, each of which returns an Observable of its correspondent property in the app store.&lt;/p&gt;

&lt;p&gt;And for each of these Observables, I need to create a subscription that will be destroyed at the end of the component lifecycle…that’s a lot of code!&lt;/p&gt;

&lt;p&gt;But what if we could get rid of all the Observables?&lt;/p&gt;

&lt;p&gt;In the simplest cases, we can avoid explicit subscriptions using the async pipe, which will subscribe to the Observable and read the last value emitted for us.&lt;/p&gt;

&lt;p&gt;Suppose that we have a @Select() decorator 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="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;Select&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;ListState&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;SelectAllItems&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nx"&gt;listItems&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Observable&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We can use it immediately with the async pipe in our HTML:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;ul&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
 &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;li&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="nx"&gt;ngFor&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;let item of listItems | async&lt;/span&gt;&lt;span class="dl"&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;item&lt;/span&gt;&lt;span class="p"&gt;}}&lt;/span&gt;
 &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/li&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/ul&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On the other hand, many cases require us to subscribe to the Observables in our components so that we can use the values they emit in other methods.&lt;/p&gt;

&lt;p&gt;(To learn about how to set up a store and see the above examples in a project, you can read my article &lt;a href="https://medium.com/better-programming/how-to-create-a-simple-store-in-angular-577a8f21a3d6"&gt; How to Create a Simple Store in Angular.&lt;/a&gt;)&lt;/p&gt;



&lt;h2&gt;
  
  
  Introducing @ngxs-labs/select-snapshot
&lt;/h2&gt;

&lt;p&gt;@ngxs-labs/select-snapshot is an experimental feature for NGXS developed by NGXS Labs.&lt;/p&gt;

&lt;p&gt;Even though it’s still not part of the official NGXS package, it is likely to become an official feature shortly. The package allows us to replace the @Select() decorator with @SelectSnapshot().&lt;/p&gt;

&lt;p&gt;But what’s the difference between them?&lt;/p&gt;

&lt;p&gt;While the former returns an Observable we need to subscribe to, the latter subscribes to the store for us and returns the last value emitted! To see it in action, let’s install the package:&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;npm&lt;/span&gt; &lt;span class="nx"&gt;install&lt;/span&gt; &lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;ngxs&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;labs&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;select&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;snapshot&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And then, let’s include it in our appModule:&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="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;NgModule&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
&lt;span class="na"&gt;declarations&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
&lt;span class="nx"&gt;AppComponent&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="nx"&gt;ListContainerComponent&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="nx"&gt;ListItemInputComponent&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="nx"&gt;ListComponent&lt;/span&gt;
&lt;span class="p"&gt;],&lt;/span&gt;
&lt;span class="na"&gt;imports&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
&lt;span class="nx"&gt;BrowserModule&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="nx"&gt;AppRoutingModule&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="nx"&gt;FormsModule&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="nx"&gt;ReactiveFormsModule&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="nx"&gt;NgxsModule&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;forRoot&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="nx"&gt;ListState&lt;/span&gt;&lt;span class="p"&gt;]),&lt;/span&gt;
&lt;span class="nx"&gt;NgxsReduxDevtoolsPluginModule&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;forRoot&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
&lt;span class="nx"&gt;NgxsSelectSnapshotModule&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;forRoot&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="p"&gt;],&lt;/span&gt;
&lt;span class="na"&gt;providers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[],&lt;/span&gt;
&lt;span class="na"&gt;bootstrap&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;AppComponent&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="nx"&gt;AppModule&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we can replace the @Select() decorator:&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;//@Select(ListState.SelectAllItems) listItems: Observable&amp;lt;string[]&amp;gt;;&lt;/span&gt;
&lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;SelectSnapshot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;ListState&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;SelectAllItems&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nx"&gt;listItems&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&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 use the value emitted from the store without subscribing!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;ul&amp;gt;&lt;/span&gt;
 &lt;span class="nt"&gt;&amp;lt;li&lt;/span&gt; &lt;span class="na"&gt;*ngFor=&lt;/span&gt;&lt;span class="s"&gt;"let item of listItems"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
   {{item}}
 &lt;span class="nt"&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/ul&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Enjoy!&lt;/p&gt;

&lt;p&gt;(This article has been originally published on &lt;a href="https://medium.com/better-programming/how-i-got-rid-of-state-observables-in-angular-2c69cbbbbd0e"&gt;Medium&lt;/a&gt;.)&lt;/p&gt;

</description>
      <category>redux</category>
      <category>typescript</category>
      <category>javascript</category>
      <category>webdev</category>
    </item>
    <item>
      <title>What Nobody Told You About Being a Great Developer</title>
      <dc:creator>~AlleAmiDev~</dc:creator>
      <pubDate>Mon, 24 Feb 2020 20:51:12 +0000</pubDate>
      <link>https://dev.to/alleamitrano/what-nobody-told-you-about-being-a-great-developer-8p4</link>
      <guid>https://dev.to/alleamitrano/what-nobody-told-you-about-being-a-great-developer-8p4</guid>
      <description>&lt;p&gt;All the roles I’ve had in these past years as a web developer have taught me something. I have met developers of many different kinds, strong and weak personalities, desirable and undesirable colleagues.&lt;/p&gt;

&lt;p&gt;All of them had something to teach me about our job, whether good or bad, and I still learn new things every day.&lt;/p&gt;

&lt;p&gt;However, two personalities left a big trace in my professional growth: the worst and the best developer I’ve ever worked with. Both of them were in a higher position than I was in two of my past roles, but not all of them gained my respect.&lt;/p&gt;

&lt;p&gt;I will briefly describe them for educational purposes, assigning them camel case nicknames:&lt;/p&gt;

&lt;p&gt;&lt;b&gt; BestDev &lt;/b&gt;&lt;/p&gt;

&lt;p&gt;Self-taught full-stack web developer of a small creative company, lead of multiple projects and mentor to many other developers.&lt;/p&gt;

&lt;p&gt;They read new things every day because they know they must never stop learning and perfecting their skills. They are not at the peak of their career but everybody respects them for two reasons:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;They explain the reasons for their choices to producers and other developers and they accept criticism.&lt;/li&gt;
&lt;li&gt;They will always make sure other developers in the office can intervene on a project in the case they are not available.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;b&gt; WorstDev &lt;/b&gt;&lt;/p&gt;

&lt;p&gt;Middle-aged IT manager of a small company. They think they have reached the peak of their career for two simple reasons:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Nobody around them has any sort of dev knowledge, so nothing they say is ever questioned.&lt;/li&gt;
&lt;li&gt;They have created legacy code that is so intricate, They’re the only one who can understand it, which make them fundamental for the survival of the company.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Obviously, I left WorstDev’s company after 6 months, as I tried to improve the tech stack and the communication in the company but hit a wall. After months of struggle on my side, it became clear that the company could not and had no intention to challenge WorstDev’s supremacy.&lt;/p&gt;

&lt;p&gt;Sometimes it’s easier to pretend all is fine.&lt;/p&gt;

&lt;p&gt;I left Italy and accepted a position in London, where I started to work as a junior front-end under the lead of BestDev. I was provided with the best tools to work, flexible hours, and a steep learning curve.&lt;/p&gt;

&lt;p&gt;It hasn’t been easy but BestDev has pushed me to be always better, including me in scoping sessions, showing me how to do things if they were not around. I worked with them for almost two years before taking the risk and looking for new opportunities to prove to myself I could make it.&lt;/p&gt;

&lt;p&gt;Now that I work in another company and I’ve gained more expertise, I have created my “Mantra of the Good Developer” to apply every day, which can be summarised in three career-changing points.&lt;/p&gt;

&lt;h1&gt;Career-Changing Points&lt;/h1&gt;

&lt;p&gt;&lt;b&gt;1. Make yourself replaceable&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;You will say: “What? I don’t want to be replaceable! I don’t want to lose my job!”&lt;/p&gt;

&lt;p&gt;Yes, I know, and that’s exactly why it’s so important. Would a good company ever fire a lead developer that instructed their teammates about how to handle emergencies? No.&lt;/p&gt;

&lt;p&gt;Would it fire a developer that takes care of training their junior colleagues? No. Why?&lt;/p&gt;

&lt;p&gt;Because the company can rely on them.&lt;/p&gt;

&lt;p&gt;I’ve been in the position of not being able to fix a critical bug because WorstDev was out of office and nobody knew how their code worked, the credentials to access the website’s database, and so on.&lt;/p&gt;

&lt;p&gt;They had created a bottleneck, a situation in which every important change had to be made by them and them alone and all the production would stop if by any chance they weren’t in.&lt;/p&gt;

&lt;p&gt;When I worked with BestDev, they made sure I knew how to tackle emergencies. They shared their knowledge with me, educating me about how to make the right choices, thus increasing my professional value for the company.&lt;/p&gt;

&lt;p&gt;Any employer of sound mind would recognize the key role of such a personality.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;2. Help everybody but keep some things to yourself&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;Helping other developers is the best way to learn. It’s important for you to test your knowledge and consolidate it.&lt;br&gt;
But it is also essential to establish a relationship with your colleagues and gain their respect. You want to be considered as someone who would help if things get nasty and a good mentor for those who have less experience.&lt;/p&gt;

&lt;p&gt;That is what BestDev was for me. Whatever question I had, they had an answer for it plus useful resources to allow me to dive deeper.&lt;br&gt;
WorstDev? Never gave me tasks that went beyond my expertise. Never shared knowledge with me.&lt;/p&gt;

&lt;p&gt;Nevertheless, helping as much as you can doesn’t mean sharing all of your knowledge.&lt;/p&gt;

&lt;p&gt;There are some cases where it’s better to keep very advanced practices to yourself, so that you’ll be able to surprise the higher ranks with your expertise. In other words:&lt;/p&gt;

&lt;p&gt;Never let them take you for granted.&lt;/p&gt;

&lt;p&gt;I try to read technical articles every day because I want to always know more to show that I’m a professional who’s growing constantly. It’s easy to be a mediocre developer, but it’s difficult to be a good one.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;You’ll never get if you never ask&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;When I got my first job in London, I was so grateful for the opportunity I got that I would have never asked for more. That’s why I didn’t even dream of asking for a good laptop.&lt;/p&gt;

&lt;p&gt;In my previous role, worstDev had taken the new laptop that was meant to be my work one and gave me their old one. I had basically acknowledged that in order to gain experience, I had to be treated like I wasn’t worthy of respect.&lt;/p&gt;

&lt;p&gt;Until a now good friend, who was my superior when I moved to the UK, told me that I’d never get anything without asking. To that, I replied that I had nothing to prove that I deserved it. I wasn’t an exceptional developer, I just worked hard every day to grow.&lt;/p&gt;

&lt;p&gt;He told me something I’ll never forget, something that I will say to you now.&lt;/p&gt;

&lt;p&gt;“It’s your right to ask. You show you deserve it with your everyday work and also, if you sell yourself cheap, you will be treated as such.”&lt;/p&gt;

&lt;p&gt;Obviously, this doesn’t mean asking for absurd raises or crazy expensive laptops. But it’s important to show that you know your value and what is necessary for you to do a good job.&lt;br&gt;
In some cases, your requests won’t be fulfilled but hey, you’ve got nothing to lose!&lt;/p&gt;

&lt;p&gt;An employer that offers you a low wage or bad working tools is an employer who is not showing respect for your skills and by accepting a similar treatment you show lack of self-respect.&lt;/p&gt;

&lt;p&gt;I asked for a new laptop and received it in a couple of weeks. I kept doing my best to pay the company back for the trust they had in me and learned that I have to respect myself and ask for respect.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Conclusion&lt;b&gt;&lt;/b&gt;&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;I hope I was able to show you the importance of these three concepts I try to apply every day.&lt;/p&gt;

&lt;p&gt;Ever since I started to apply them, I’ve never stopped learning and feeling more and more confident in my capabilities. I hope my experience will help you too in making the best of your skills!&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>career</category>
      <category>devlive</category>
      <category>womenintech</category>
    </item>
    <item>
      <title>A New Way of Dispatching Actions With Ngxs for Angular</title>
      <dc:creator>~AlleAmiDev~</dc:creator>
      <pubDate>Mon, 24 Feb 2020 18:12:12 +0000</pubDate>
      <link>https://dev.to/alleamitrano/a-new-way-of-dispatching-actions-with-ngxs-for-angular-91k</link>
      <guid>https://dev.to/alleamitrano/a-new-way-of-dispatching-actions-with-ngxs-for-angular-91k</guid>
      <description>&lt;p&gt;Another fundamental priority in development is trying to limit the use of boilerplates to the minimum. In general, it’d be good practice to keep the code as simple as possible and to avoid verbosity to keep technical debt under control.&lt;/p&gt;

&lt;p&gt;For me, there’s nothing more frustrating than a file with hundreds of lines of code, and that’s why I’m always looking for ways to write in a cleaner and clearer way. In this piece, I’ll show you a better way to dispatch actions to an Angular NgXs Store.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;The problem&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;Writing boilerplate code for our state management can be a long process. If we’re working on a complex app with a wide range of operations handled by the Store, we might need tens of different @Select() functions (as well as Action declarations).&lt;br&gt;
When it comes to dispatching actions from our components, we can easily find situations like this below, where we’re dispatching multiple updates to the Store to perform a series of different actions before routing to the success page:&lt;/p&gt;

&lt;p&gt;&lt;b&gt;The Solution: Introducing the Dispatch Decorator&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;@ngxs-labs/dispatch-decorator is another interesting experimental feature for NGXS developed by NGXS Labs.&lt;/p&gt;

&lt;p&gt;Even though it’s still not part of the official NGXS package, it’s likely to become an official feature shortly. The package allows us to use the @Dispatch decorator without injecting the Store in the constructor of our component. Moreover, it helps us writing code that is much more compact.&lt;/p&gt;

&lt;p&gt;We can install it using the script:&lt;br&gt;
&lt;code&gt;npm i @ngxs-labs/dispatch-decorator&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;And we can include it in our app.module.ts:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;import { NgModule } from '@angular/core';&lt;br&gt;
import { NgxsModule } from '@ngxs/store';&lt;br&gt;
import { NgxsDispatchPluginModule } from '@ngxs-labs/dispatch-decorator';&lt;br&gt;
@NgModule({&lt;br&gt;
imports: [&lt;br&gt;
NgxsModule.forRoot(CartState, ProductState),&lt;br&gt;
NgxsDispatchPluginModule.forRoot()&lt;br&gt;
]&lt;br&gt;
})&lt;br&gt;
export class AppModule {}&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Now, we’re ready to replace our calls to the Store with the @Dispatch decorator:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;import { Dispatch } from '@ngxs-labs/dispatch-decorator';&lt;br&gt;
export class PurchasePageComponent {&lt;br&gt;
 @Input() defaultState: any;&lt;br&gt;
constructor() {}&lt;br&gt;
showSuccessPage(): void {&lt;br&gt;
this.resetAllStates();&lt;br&gt;
this.goToPage(['success']);&lt;br&gt;
}&lt;br&gt;
@Dispatch() resetAllStates = () =&amp;gt;[&lt;br&gt;
new ResetAnimationState(this.defaultState),&lt;br&gt;
new ResetPurchaseState(),&lt;br&gt;
new HideHeader(),&lt;br&gt;
new ResetAnswers(),&lt;br&gt;
new ResetCartState(),&lt;br&gt;
new ResetCarouselState(),&lt;br&gt;
new ResetUserState()&lt;br&gt;
];&lt;br&gt;
@Dispatch goToPage = (route: any) =&amp;gt; new RouterGo({path: route});&lt;br&gt;
}&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Much better. Enjoy!&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>angular</category>
      <category>redux</category>
      <category>typescript</category>
    </item>
  </channel>
</rss>
