<?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: negue</title>
    <description>The latest articles on DEV Community by negue (@negue).</description>
    <link>https://dev.to/negue</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%2F167669%2Fcfb5840a-f71c-41f7-82ce-ea4431bc4669.png</url>
      <title>DEV Community: negue</title>
      <link>https://dev.to/negue</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/negue"/>
    <language>en</language>
    <item>
      <title>Senstate - Updates, C#-Client and a future look</title>
      <dc:creator>negue</dc:creator>
      <pubDate>Thu, 11 Jun 2020 21:25:06 +0000</pubDate>
      <link>https://dev.to/negue/senstate-updates-c-client-and-a-future-look-n1</link>
      <guid>https://dev.to/negue/senstate-updates-c-client-and-a-future-look-n1</guid>
      <description>&lt;p&gt;&lt;a href="https://senstate-dashboard-master.netlify.app/#/"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--i4bs8aLv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/zmtm5zab2vlu51qnnnda.gif" alt="Example Senstate Gif"&gt; &lt;br&gt; Demo&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Finally after some months I worked a bit on Senstate again. I had some features already "done", but only some days ago I merged the PR. 😄&lt;/p&gt;

&lt;h1&gt;
  
  
  🎊 Senstate v0.3 🎉
&lt;/h1&gt;

&lt;p&gt;New features:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Group Watchers&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--TsMDpMXP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://user-images.githubusercontent.com/842273/84432637-610d7880-ac2d-11ea-8cd1-cefa4177b9c8.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--TsMDpMXP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://user-images.githubusercontent.com/842273/84432637-610d7880-ac2d-11ea-8cd1-cefa4177b9c8.PNG" alt="group_feature"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;List Watchers (instead of a masonry-grid, still need some more stying, ideas? thoughts?)&lt;/li&gt;
&lt;li&gt;You can add "difference"-View to see the change of the previous value&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--iD5Bckb6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://user-images.githubusercontent.com/842273/84432324-f65c3d00-ac2c-11ea-9dc6-f84a4328e5d3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--iD5Bckb6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://user-images.githubusercontent.com/842273/84432324-f65c3d00-ac2c-11ea-9dc6-f84a4328e5d3.png" alt="example of the difference feature"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Errors can be searched on multiple sites, opens a new tab:

&lt;ul&gt;
&lt;li&gt;DuckDuckGo&lt;/li&gt;
&lt;li&gt;Github&lt;/li&gt;
&lt;li&gt;Google&lt;/li&gt;
&lt;li&gt;StackOverflow&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Also see &lt;a href="https://github.com/senstate/platform/blob/master/CHANGELOG.md"&gt;CHANGELOG.md&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  🚧 Whats next?
&lt;/h1&gt;

&lt;h2&gt;
  
  
  In-Web-App-Overlay
&lt;/h2&gt;

&lt;p&gt;Began working on an overlay to use inside your Web-App.&lt;/p&gt;

&lt;p&gt;This will be done with Angular Elements (which can be used even without Angular).&lt;/p&gt;

&lt;p&gt;Only the "target" connection will be changed (instead of the Hub-Connection), everything else will stay the same.&lt;/p&gt;

&lt;p&gt;Repo / wip-changes will be pushed soon&lt;/p&gt;

&lt;h2&gt;
  
  
  Now finally working on the C# client:
&lt;/h2&gt;

&lt;p&gt;My goal is to create a library that could be used with, initial tests worked with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;.Net Standard (I hope this would be all possible targets?)&lt;/li&gt;
&lt;li&gt;Unity&lt;/li&gt;
&lt;li&gt;Blazor Server / WebAssembly&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The Library(ies) will be splitted into:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The main logic, watchers/logger&lt;/li&gt;
&lt;li&gt;separated WebSockets implementation&lt;/li&gt;
&lt;li&gt;separated Json implementation&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So that way every possible Target / Platform can have their own Json/WebSocket implementation.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/senstate/csharp-client"&gt;Repo&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;I'll post an article on how to use it, once the first version  is published&lt;/p&gt;

&lt;h2&gt;
  
  
  Misc
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Try if react-native "just" works ?&lt;/li&gt;
&lt;li&gt;Save Dashboard settings to localStorage&lt;/li&gt;
&lt;li&gt;Extend the Dashboard (all the time, suggestions welcomed)&lt;/li&gt;
&lt;li&gt;Add instructions to the Dashboard itself (if no app is connected) - maybe just show the markdown-file of the client-library? - ideas?&lt;/li&gt;
&lt;li&gt;Creating an example repo for all possible libraries / targets&lt;/li&gt;
&lt;li&gt;Bug fixes&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Feedback
&lt;/h1&gt;

&lt;p&gt;If there are any ideas / feature requests / issues / use-cases, please tell me :)&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>angular</category>
      <category>csharp</category>
      <category>senstate</category>
    </item>
    <item>
      <title>Working with graph structures</title>
      <dc:creator>negue</dc:creator>
      <pubDate>Mon, 18 May 2020 20:21:24 +0000</pubDate>
      <link>https://dev.to/negue/working-with-graph-structures-2006</link>
      <guid>https://dev.to/negue/working-with-graph-structures-2006</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;Preamble: I'm not that experienced in graph-theory or like getting the shortest path to a node. :) This article is rather a short introduction into "How to re-create your usual list-states into a graph/object structure - in addition: with some examples using &lt;a href="https://github.com/amark/gun"&gt;GunDB/GunJS&lt;/a&gt;" &lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  What is GunDB/GunJS ?
&lt;/h2&gt;

&lt;p&gt;Its an offline-first, distributed, p2p synced graph-database created by &lt;a href="https://github.com/amark"&gt;Mark Nadal&lt;/a&gt;. You can also create accounts (offline) and encrypt data nodes. Enough buzzwords but also true. More info's at the &lt;a href="https://github.com/amark/gun"&gt;repo&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Example of working with the API and simple data
&lt;/h2&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;gun&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;Gun&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="nx"&gt;gun&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kd"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;node&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;put&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;someString&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Mark&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;someNumber&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;42&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="nx"&gt;gun&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kd"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;othernode&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="kd"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;sub&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;put&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="c1"&gt;// ...some other props&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="c1"&gt;// sets the data in put, to the node "othernode.sub"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;You have the following api's:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;.get('YOUR_NODE')&lt;/code&gt; - just says "go to the node of YOUR_NODE" , and all other operations will be done from this one 
&amp;gt; note: this does not get the actual value&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;.put()&lt;/code&gt; - sets the data in the current node-context&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;.once(callback)&lt;/code&gt; - gets the data &lt;code&gt;once&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;there are also other callback types which get the updates all the time - or like normal promises using &lt;code&gt;.then&lt;/code&gt;
&amp;gt; &lt;a href="https://github.com/amark/gun/wiki/API"&gt;see Docs&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Working with lists in a object/graph-world
&lt;/h2&gt;

&lt;p&gt;Gun can't really work with lists, due to the syncing between peers is based on properties. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;This part can be theoretically also used with any redux-like state outside of gun.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Your usual lists look (probably) 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;myList&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="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;someId&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;string&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;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;otherId&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;other string&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="c1"&gt;// or object&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;If you want to move an item in your list or edit this item, you'd either:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;create a new array, which has the items order / new value&lt;/li&gt;
&lt;li&gt;or move item A to new pos X, and the re-set all other affected items to their new pos&lt;/li&gt;
&lt;li&gt;maybe some other way I forgot&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A better graph-way would be something 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;state&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;yourlist&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="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;nodes&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="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;someId&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;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;someId&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                    &lt;span class="na"&gt;data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;string&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
                &lt;span class="p"&gt;},&lt;/span&gt;  &lt;span class="c1"&gt;// or just use the data, if you want to optimize&lt;/span&gt;
      &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;otherId&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;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;otherId&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                     &lt;span class="na"&gt;data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;other string&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="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;order&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="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;someId&lt;/span&gt;&lt;span class="dl"&gt;"&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="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;otherId&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;At first glance it looks like a lot of unneeded / redundant stuff right?&lt;/p&gt;

&lt;p&gt;With this type of state:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;you only have 2 operations when switching a position of two items&lt;/li&gt;
&lt;li&gt;you only have 1 operation when changing the data of a node&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;Note: Less operations, means less data to sync =&amp;gt; faster&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;But you probably ask yourself, "what If I just set the whole &lt;code&gt;yourlist&lt;/code&gt;-node, wouldn't that just work?" - Yes, if you just subscribe only to this one node, you don't need any optimization. Then you could just add the order property to node. &lt;/p&gt;

&lt;p&gt;I choose this structure, because I had encrypted data nodes and when the whole list changed, I had to de-crypt all nodes on each new callback - which is wasted CPU / Page performance. But with that optimized structure, I could handle this much easier, without having to use something like an "object-differ":&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Subscription: "the order changed" =&amp;gt; just move item to different place&lt;/li&gt;
&lt;li&gt;Subscription: "the data changed" =&amp;gt; load the newest update -&amp;gt; decrypt -&amp;gt; show it&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Sure, this still is not the "perfect" solution, for example: When you have 100 items, and you want to move Item 44 to 55, you'd have to do 12 operations.&lt;/p&gt;

&lt;p&gt;If you want to optimize this even further, you could implement a linked list, with this you could even decrease the number operations, to about 3.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Note: It all depends on the amount of your data.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;But how to get the correct order again?&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="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;nodes&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;order&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;state&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;yourlist&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;orderedList&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;values&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;nodes&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
      &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;sort&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;order&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;a&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="o"&gt;-&lt;/span&gt; &lt;span class="nx"&gt;order&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;b&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;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  Working with lists in a GunDB-World
&lt;/h2&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;gun&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;Gun&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="c1"&gt;// Saving data&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;graphNode&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;gun&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kd"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;your_list&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;nodes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;graphNode&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kd"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;nodes&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;order&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;graphNode&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kd"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;order&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="nx"&gt;nodes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kd"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;someId&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
      &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;put&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="s1"&gt;someId&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;string&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
      &lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="nx"&gt;nodes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kd"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;otherId&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
      &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;put&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="s1"&gt;otherId&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;other string&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
      &lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="nx"&gt;order&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kd"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;someId&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
     &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;put&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="nx"&gt;order&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kd"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;otherId&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
     &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;put&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// react on changed data (or reading from gun) &lt;/span&gt;
&lt;span class="nx"&gt;graphNode&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;on&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;listData&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="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;nodes&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;order&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;listData&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;orderedList&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;values&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;nodes&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;sort&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;order&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;a&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="o"&gt;-&lt;/span&gt; &lt;span class="nx"&gt;order&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;b&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="c1"&gt;// work with the list, send it to your views etc&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;I hope this was an "easy"-ish intro to list-handling with GunDB and or object-only states, if not please write me on how it could be made better?&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>graph</category>
      <category>gundb</category>
      <category>datastructure</category>
    </item>
    <item>
      <title>Dynamic Layout parts in Angular</title>
      <dc:creator>negue</dc:creator>
      <pubDate>Fri, 27 Dec 2019 20:37:23 +0000</pubDate>
      <link>https://dev.to/negue/dynamic-layout-parts-in-angular-49g7</link>
      <guid>https://dev.to/negue/dynamic-layout-parts-in-angular-49g7</guid>
      <description>&lt;h2&gt;
  
  
  The "Problem"
&lt;/h2&gt;

&lt;p&gt;While working on a simple application I wanted to show some content in the title / header bar, but this should be only visible on a specific route.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;header.component.html&lt;/em&gt;:&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;"header"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;ng-container&lt;/span&gt; &lt;span class="na"&gt;*ngIf=&lt;/span&gt;&lt;span class="s"&gt;"!showSuperSelection"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;{{ title }}&lt;span class="nt"&gt;&amp;lt;/ng-container&amp;gt;&lt;/span&gt;
  &lt;span class="c"&gt;&amp;lt;!-- this component is only needed in an "/selected-page" - route --&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;app-your-big-component&lt;/span&gt; &lt;span class="na"&gt;*ngIf=&lt;/span&gt;&lt;span class="s"&gt;"showSuperSelection"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/app-your-big-component&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;h2&gt;
  
  
  1st solution: &lt;code&gt;*ngIf&lt;/code&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;"just" hide (&lt;code&gt;*ngIf="showSuperSelection"&lt;/code&gt;, exampled in the problem) the content in the header-bar until the specific route was opened&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Pro's&lt;/th&gt;
&lt;th&gt;Con's&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;easy to use, just an &lt;code&gt;*ngIf&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;its "bad" if this content is a bigger component (byte size), which adds a lot of to the first loading time (every byte counts), which is only "ok" if you are building an intranet-application&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;
&lt;h2&gt;
  
  
  2nd solution: Service - ng-template - template outlet
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;You could create a directive to get &lt;code&gt;TemplateRef&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;then using a service to save that reference&lt;/li&gt;
&lt;li&gt;then in your target view, get this reference and use it like
&lt;/li&gt;
&lt;/ul&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;ng-container&lt;/span&gt; &lt;span class="na"&gt;*ngIf=&lt;/span&gt;&lt;span class="s"&gt;"templateToShow$ | async as templateRef"&lt;/span&gt;
                &lt;span class="na"&gt;[ngTemplateOutlet]=&lt;/span&gt;&lt;span class="s"&gt;"templateRef"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/ng-container&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;There you have your dynamic templates / layout parts in your app.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Pro's&lt;/th&gt;
&lt;th&gt;Con's&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;now this template would be only visible when you need it, and also not adding additional bytes to load&lt;/td&gt;
&lt;td&gt;you would've to do it for every part you need&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;
&lt;h2&gt;
  
  
  My solution: 🚀 &lt;br&gt; &lt;code&gt;npm install @gewd/ng-utils -S&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;Building up on the 2nd's solution, I kinda wanted to have it a bit more dynamic, so I refacted it to be used on a ID per portal/source.&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="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;DynamicPortalModule&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;@gewd/ng-utils/dynamic-portal&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;imports&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="c1"&gt;// ...&lt;/span&gt;
    &lt;span class="nx"&gt;DynamicPortalModule&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;&lt;em&gt;header.component.html&lt;/em&gt;:&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;"header"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;dynamic-portal&lt;/span&gt; &lt;span class="na"&gt;key=&lt;/span&gt;&lt;span class="s"&gt;"headerSelection"&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"your-style"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    {{ title }}
  &lt;span class="nt"&gt;&amp;lt;/dynamic-portal&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;&lt;em&gt;selected-page.component.html&lt;/em&gt;: which is a lazy-loaded route&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;"stuff"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  Much stuff, details, you name it :-)
&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;ng-template&lt;/span&gt; &lt;span class="na"&gt;dynamicPortalSource=&lt;/span&gt;&lt;span class="s"&gt;"headerSelection"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
   &lt;span class="nt"&gt;&amp;lt;app-your-big-component&amp;gt;&amp;lt;/app-your-big-component&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/ng-template&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;a href="https://gewd-packages-demo.netlify.com/" rel="noopener noreferrer"&gt;&amp;gt; Demo &amp;lt;&lt;/a&gt; -&amp;gt; Open the &lt;code&gt;Dynamic Portal Component&lt;/code&gt; Part&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Pro's&lt;/th&gt;
&lt;th&gt;Con's&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;portal's / portal-sources can be placed anywhere&lt;/td&gt;
&lt;td&gt;you'd need to use this package or copy it 😁&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev.to%2Fassets%2Fgithub-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/negue" rel="noopener noreferrer"&gt;
        negue
      &lt;/a&gt; / &lt;a href="https://github.com/negue/gewd" rel="noopener noreferrer"&gt;
        gewd
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      List of utilities / components around Angular
    &lt;/h3&gt;
  &lt;/div&gt;
&lt;/div&gt;



&lt;p&gt;Any ideas / issues / suggestions, write here or open an issue :)&lt;/p&gt;

</description>
      <category>angular</category>
      <category>optimization</category>
    </item>
    <item>
      <title>Lazy Loaded Components - #4 NPM-Package</title>
      <dc:creator>negue</dc:creator>
      <pubDate>Wed, 25 Dec 2019 22:14:47 +0000</pubDate>
      <link>https://dev.to/negue/lazy-loaded-components-4-npm-package-ab9</link>
      <guid>https://dev.to/negue/lazy-loaded-components-4-npm-package-ab9</guid>
      <description>&lt;h1&gt;
  
  
  Proudly presenting &lt;code&gt;npm install @gewd/lazy -S&lt;/code&gt; 😉
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://www.npmjs.com/package/@gewd/lazy" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimg.shields.io%2Fnpm%2Fv%2F%40gewd%2Flazy.svg%3F" alt="NPM Version"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Finally, the demo-repository and loader package is done. Here are some of the changes:&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;code&gt;Lazy&lt;/code&gt;-Helper
&lt;/h2&gt;

&lt;p&gt;Like the C# Lazy-Class, I created a simple helper, which holds the lazy-Value once its already have been requested.&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="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;Lazy&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;@gewd/lazy/utils&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// create&lt;/span&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;myLazy&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;Lazy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="cm"&gt;/*...*/&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

&lt;span class="c1"&gt;// callback/promise will be only executed once `.getValue()` is called&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;myLazy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getValue&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="c1"&gt;// once the value was loaded, it'll just use this cached promise&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;In the previously articles you saw that I cached the requests, in a separate dictionary, with this I don't need to handle that.&lt;/p&gt;
&lt;h2&gt;
  
  
  Lazy Components
&lt;/h2&gt;

&lt;p&gt;As you can see the registration of LazyComponents changed a bit, now using the Lazy-Helper.&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;// Register the lazy component, without a module&lt;/span&gt;
&lt;span class="nx"&gt;DynamicLoaderRegistry&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;LazyComponents&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="s1"&gt;test-comp&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;Lazy&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kr"&gt;any&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./lazy-wrapper/test-comp&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;Use it inside your app with:&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;gewd-lazy-component&lt;/span&gt; 
   &lt;span class="na"&gt;[componentInputs]=&lt;/span&gt;&lt;span class="s"&gt;"{ testProp: 'Component Binding from outside' }"&lt;/span&gt;
   &lt;span class="na"&gt;component=&lt;/span&gt;&lt;span class="s"&gt;"test-comp"&lt;/span&gt;
&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
   Normal content that is visible the content isn't loaded.

   &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;isLoading&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
      This content will be visible while the component is loading / being created.
   &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;                  
&lt;span class="nt"&gt;&amp;lt;/gewd-lazy-component&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;This is useful for components that don't need any other module's or using 3rd party web-components.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Note, using components of the host-module not working yet.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;But for this issue I created the lazy-components (using modules), this type of lazy-loading has been around for quite a while, there are existing libraries for this, but here is my approach :) &lt;/p&gt;
&lt;h2&gt;
  
  
  Lazy Module Components
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="nx"&gt;DynamicLoaderRegistry&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;LazyModuleComponents&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="s1"&gt;test-module&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;load&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;Lazy&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kr"&gt;any&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
      &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./lazy-wrapper/test-module-comp&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="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(({&lt;/span&gt;&lt;span class="nx"&gt;TestModule&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;TestModule&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Your lazy module need to implement &lt;code&gt;LazyModule&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="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;MyModuleComp&lt;/span&gt; &lt;span class="c1"&gt;// Your Component&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;CommonModule&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nx"&gt;MatButtonModule&lt;/span&gt; &lt;span class="c1"&gt;// any dependent module&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;TestModule&lt;/span&gt; &lt;span class="k"&gt;implements&lt;/span&gt; &lt;span class="nx"&gt;LazyModule&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;getComponents &lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt; &lt;span class="nx"&gt;LazyModuleComponentInfo&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="p"&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="s1"&gt;MyModuleComp&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="c1"&gt;// key to access it&lt;/span&gt;
        &lt;span class="na"&gt;componentType&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;MyModuleComp&lt;/span&gt;  &lt;span class="c1"&gt;// your component&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;];&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Use it inside your app with:&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;gewd-lazy-module-component&lt;/span&gt;
    &lt;span class="na"&gt;[componentInputs]=&lt;/span&gt;&lt;span class="s"&gt;"{ testProp: 'Module Component Example' }"&lt;/span&gt;
    &lt;span class="na"&gt;[componentOutputs]=&lt;/span&gt;&lt;span class="s"&gt;"outputBinding"&lt;/span&gt;
    &lt;span class="na"&gt;moduleAlias=&lt;/span&gt;&lt;span class="s"&gt;"test-module"&lt;/span&gt;
    &lt;span class="na"&gt;component=&lt;/span&gt;&lt;span class="s"&gt;"MyModuleComp"&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
   Normal content that is visible the content isn't loaded.

   &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;isLoading&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
      This content will be visible while the component is loading / being created.
   &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;  
&lt;span class="nt"&gt;&amp;lt;/gewd-lazy-module-component&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev.to%2Fassets%2Fgithub-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/negue" rel="noopener noreferrer"&gt;
        negue
      &lt;/a&gt; / &lt;a href="https://github.com/negue/gewd" rel="noopener noreferrer"&gt;
        gewd
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      List of utilities / components around Angular
    &lt;/h3&gt;
  &lt;/div&gt;
&lt;/div&gt;



&lt;p&gt;Any ideas / issues / suggestions, write here or open an issue :)&lt;/p&gt;

</description>
      <category>angular</category>
      <category>lazyloaded</category>
      <category>ivy</category>
      <category>performance</category>
    </item>
    <item>
      <title>ERROR in Maximum call stack size exceeded - the unsual kind</title>
      <dc:creator>negue</dc:creator>
      <pubDate>Mon, 16 Dec 2019 23:41:21 +0000</pubDate>
      <link>https://dev.to/negue/error-in-maximum-call-stack-size-exceeded-the-unsual-kind-gg1</link>
      <guid>https://dev.to/negue/error-in-maximum-call-stack-size-exceeded-the-unsual-kind-gg1</guid>
      <description>&lt;p&gt;Wow.... who would've known that the next issue would be right at the corner so soon. 😁&lt;/p&gt;

&lt;p&gt;I'm working on a markdown component, and I needed a list of colon emoji keys's (&lt;code&gt;:smile:&lt;/code&gt;) to have simple overview for them 😄&lt;/p&gt;

&lt;p&gt;While angular was running, I created this &lt;a href="https://gist.github.com/negue/2110c5f87cad2367ddc65729454ded9b#file-example-emoji-list-ts"&gt;&amp;gt; file &amp;lt;&lt;/a&gt; nothing happened.&lt;/p&gt;

&lt;p&gt;When I imported it...&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;code&gt;ERROR in RangeError: Maximum call stack size exceeded&lt;/code&gt; happened
&lt;/h2&gt;

&lt;p&gt;.... ok what ... why?!&lt;/p&gt;

&lt;p&gt;Usually this error means, some module imported a different one which imported the previous one, which imported "the different"-one ... and so on.&lt;/p&gt;

&lt;p&gt;Or it means just any methods called itself until the stack exceeded, but it wasn't a runtime error, it was a compiler error.&lt;/p&gt;

&lt;h2&gt;
  
  
  Ok. Weird.
&lt;/h2&gt;

&lt;p&gt;What did I do before it... "just added a file"... right?&lt;/p&gt;

&lt;p&gt;To make sure it is not a hiccup again, I restarted angular/typescript.&lt;/p&gt;

&lt;p&gt;The error still happens.&lt;/p&gt;

&lt;p&gt;Removed the file and its working again?!&lt;/p&gt;

&lt;h2&gt;
  
  
  Lets try to debug it again.
&lt;/h2&gt;

&lt;p&gt;Added the file back and started angular in verbose mode.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ERROR in RangeError: Maximum call stack size exceeded
    at needsIndentation 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;





&lt;div class="highlight"&gt;&lt;pre class="highlight typescript"&gt;&lt;code&gt;        &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;needsIndentation&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;parent&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;node1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;node2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nx"&gt;parent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;skipSynthesizedParentheses&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;parent&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
            &lt;span class="nx"&gt;node1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;skipSynthesizedParentheses&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;node1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
            &lt;span class="nx"&gt;node2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;skipSynthesizedParentheses&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;node2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Sadly I haven't took a deep-dive into typescript (yet), but today wouldn't be the day either 😁, but maybe there was already anything anywhere =&amp;gt; searched for the first 2 lines, but I couldn't find anything useful.&lt;/p&gt;

&lt;h2&gt;
  
  
  Solution. 🎉
&lt;/h2&gt;

&lt;p&gt;Use an array of strings and then just &lt;code&gt;.join()&lt;/code&gt; them together. &lt;a href="https://gist.github.com/negue/2110c5f87cad2367ddc65729454ded9b#file-working-emoji-list-ts"&gt;&amp;gt; Gist &amp;lt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>typescript</category>
      <category>angular</category>
    </item>
    <item>
      <title>No template for dependency: "ConstDependency"</title>
      <dc:creator>negue</dc:creator>
      <pubDate>Sat, 14 Dec 2019 00:43:59 +0000</pubDate>
      <link>https://dev.to/negue/no-template-for-dependency-constdependency-g9p</link>
      <guid>https://dev.to/negue/no-template-for-dependency-constdependency-g9p</guid>
      <description>&lt;p&gt;Over the past years, I came across so many weird issues while developing and most of them I couldn't find any mentions or articles or even any stackoverflow posts.&lt;/p&gt;

&lt;p&gt;Yesterday I had another one of these and since I want to write more articles why not create weird issues series? Welcome to the first part of this series 😁&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;code&gt;No template for dependency: "ConstDependency"&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;While trying to add a simple worker in angular, like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;markdownWorker&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;Worker&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./markdown.worker.ts&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;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;markdown&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;module&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;I got this error message.&lt;/p&gt;

&lt;p&gt;Like I already wrote "no real results about it", just some for &lt;code&gt;No template for dependency:&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;I tried multiple times switching the angular version (9 rc5 / 6), which also meant deleting and reinstalling all packages.&lt;/p&gt;

&lt;p&gt;-- still not working&lt;/p&gt;

&lt;p&gt;I created a new project (different folder) it just works &lt;code&gt;out of box&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Compared the angular.json / tsconfig / packages - copied even the app to the other folder , in that other folder everything is working fine.&lt;/p&gt;

&lt;p&gt;Tracked down where message issue was written:&lt;br&gt;
&lt;code&gt;/node_modules/@angular-devkit/build-angular/node_modules/webpack/lib/&lt;/code&gt; =&amp;gt; &lt;a href="https://github.com/webpack/webpack/blob/v4.41.2/lib/JavascriptGenerator.js#L144-L152"&gt;https://github.com/webpack/webpack/blob/v4.41.2/lib/JavascriptGenerator.js#L144-L152&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Added a bit more outputs to that, and the issue was that the ConstDependency-constructor couldn't be found in the &lt;code&gt;dependencyTemplates&lt;/code&gt;-Map. But my additional logs show that &lt;code&gt;dependencyTemplates&lt;/code&gt; did actually had a &lt;code&gt;ConstDependency&lt;/code&gt; key.&lt;/p&gt;

&lt;p&gt;I rewrote the &lt;code&gt;const template = dependencyTemplates.get(dependency.constructor);&lt;/code&gt; part to check for the constructor-names instead, and look it works. 🎉&lt;/p&gt;

&lt;p&gt;I still don't understand why the contructor of &lt;code&gt;dependency&lt;/code&gt; wasn't the same as in the map.&lt;/p&gt;

&lt;p&gt;Checked my node version, maybe just an older version issue, updated to &lt;code&gt;12.13.1&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;I ran &lt;code&gt;npm prune&lt;/code&gt;, and this folder &lt;code&gt;/node_modules/@angular-devkit/build-angular/node_modules/webpack/lib/&lt;/code&gt; was gone!, after the many.. removal and &lt;code&gt;npm install&lt;/code&gt;s  that folder was always there (throwing this issue)&lt;/p&gt;

&lt;p&gt;Again started &lt;code&gt;ng serve&lt;/code&gt; .... aaaand its gone! &lt;/p&gt;

&lt;h1&gt;
  
  
  😁
&lt;/h1&gt;




&lt;p&gt;Did &lt;strong&gt;you&lt;/strong&gt; had any of those weird issues lately? Would like to read about those, and also like to know if you could fix it anyway. :)&lt;/p&gt;

</description>
      <category>webpack</category>
      <category>angular</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Senstate - Make sense of your state while debugging</title>
      <dc:creator>negue</dc:creator>
      <pubDate>Tue, 29 Oct 2019 17:02:38 +0000</pubDate>
      <link>https://dev.to/negue/senstate-make-sense-of-your-state-while-debugging-96f</link>
      <guid>https://dev.to/negue/senstate-make-sense-of-your-state-while-debugging-96f</guid>
      <description>&lt;p&gt;Having sometimes multiple &lt;code&gt;console.log&lt;/code&gt;s while trying to find a bug that only happens with a weird state, you kinda get lost scrolling the log up and down. Or adding a bunch of break-points and then stepping into multiple ones. In the past years this happened quite often to me, and last month I thought it needs be easier to debug / see important variables while working on your project.&lt;/p&gt;

&lt;p&gt;Fast forward until today.&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%2Fzmtm5zab2vlu51qnnnda.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fzmtm5zab2vlu51qnnnda.gif" alt="Example Senstate Gif"&gt;&lt;/a&gt;&lt;/p&gt;
Senstate "Debug" Dashboard



&lt;h2&gt;
  
  
  🎊 Introducing &lt;code&gt;@senstate/cli&lt;/code&gt; 🎉
&lt;/h2&gt;

&lt;p&gt;The cli acts as an hub to accept client-events (via WebSockets) and send them to the dashboard. &lt;/p&gt;

&lt;p&gt;Current features:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;watch variables / state of your application&lt;/li&gt;
&lt;li&gt;send logs&lt;/li&gt;
&lt;li&gt;send errors&lt;/li&gt;
&lt;li&gt;open dashboard via qr-code on a phone / tablet (to free up a monitor/space)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Current available client libraries:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://github.com/senstate/platform/blob/master/libs/client/README.md" rel="noopener noreferrer"&gt;🔗 JS/TS&lt;/a&gt; (exampled in this article)&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/dnaka91/senstate-rs" rel="noopener noreferrer"&gt;🔗 Rust&lt;/a&gt; (by &lt;a href="https://dnaka91.netlify.com" rel="noopener noreferrer"&gt;🔗 dnaka91&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/dnaka91/senstate-go" rel="noopener noreferrer"&gt;🔗 Go&lt;/a&gt; (by &lt;a href="https://dnaka91.netlify.com" rel="noopener noreferrer"&gt;🔗 dnaka91&lt;/a&gt;)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;more libraries in progress:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;C#&lt;/li&gt;
&lt;li&gt;Kotlin (by &lt;a href="https://dnaka91.netlify.com" rel="noopener noreferrer"&gt;🔗 dnaka91&lt;/a&gt;)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Add it to your project
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Install the client
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;npm install @senstate/client&lt;/code&gt; contains the utils / methods, not actually sending anything to the hub&lt;/p&gt;

&lt;p&gt;&lt;code&gt;npm install @senstate/client-connection&lt;/code&gt; is used to send the data to the hub. I wanted to have it separately if for example it would send to other hubs / or different protocols.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Register your app:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&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;setSenstateConnection&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="s2"&gt;@senstate/client-connection&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nf"&gt;setSenstateConnection&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="s1"&gt;My Example App&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="c1"&gt;// appId: 'customShortId' optional&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;  &lt;span class="cm"&gt;/* , ws://localhost:3333 */&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// custom hub-address, working locally you won't need to change the target address&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Without calling &lt;code&gt;setStenstateConnection&lt;/code&gt; all watchers/senders won't send anything to the Dashboard.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Low-Level Watcher / Senders
&lt;/h3&gt;

&lt;p&gt;You can create a sender and call it how often you like to push the values to the Dashboard:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Watch&lt;/strong&gt; (for variables): Sends a value of a tag:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;watcher&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;createWatchSender&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;myTag&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="nf"&gt;watcher&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;yourVariableOrValueToSend&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// where you need it&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Log&lt;/strong&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="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;logger&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;createLogSender&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;LogLevel&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Info&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;optional log name&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;


&lt;span class="nf"&gt;logger&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;message to send&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;optionalObject&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;can be empty :)&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Errors&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Un-caught window errors will be send to the hub with:&lt;br&gt;
&lt;code&gt;registerWindowErrorHandler()&lt;/code&gt; (call once)&lt;/p&gt;



&lt;br&gt;
You can use the senders above, but there is also some code-candy 🍭
&lt;h3&gt;
  
  
  4. Field decorators
&lt;/h3&gt;

&lt;p&gt;Automatically sends the value on a change to the hub 🎉&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;YourClass&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;PropertyWatcher&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;watchProperty&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="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;PropertyWatcher&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;otherKey&lt;/span&gt;&lt;span class="dl"&gt;'&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;watchOtherProperty&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="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  5. RXJS pipes
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&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;SenstateOperators&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;@senstate/client&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nx"&gt;myObservable$&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;pipe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
   &lt;span class="nx"&gt;SenstateOperators&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;watch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Watcher Tag&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="c1"&gt;// Watcher&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="nx"&gt;other$&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;pipe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
   &lt;span class="nx"&gt;SenstateOperators&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Log Name&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="c1"&gt;// Measure time between pipe-operators&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;time&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;TimeMeasurer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;tag&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="nx"&gt;trigger$&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;pipe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
   &lt;span class="nx"&gt;SenstateOperators&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;measureStart&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;time&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
   &lt;span class="nf"&gt;mergeMap&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;longerObservableExecution$&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
   &lt;span class="nx"&gt;SenstateOperators&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;measureStep&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;time&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;
  
  
  🚧 Whats next?
&lt;/h2&gt;

&lt;p&gt;The project is still WIP, but I hope it'll help you.&lt;/p&gt;

&lt;p&gt;The Dashboard isn't that polished yet, but I'm sure it'll be better after a few iterations.&lt;/p&gt;

&lt;p&gt;If there are any ideas / feature requests / issues, please tell me :)&lt;/p&gt;

</description>
      <category>showdev</category>
      <category>javascript</category>
      <category>typescript</category>
      <category>node</category>
    </item>
    <item>
      <title>Lazy Loaded Components  - #3 Extending the Loader</title>
      <dc:creator>negue</dc:creator>
      <pubDate>Tue, 01 Oct 2019 17:57:36 +0000</pubDate>
      <link>https://dev.to/negue/lazy-loaded-components-3-extending-the-loader-59j5</link>
      <guid>https://dev.to/negue/lazy-loaded-components-3-extending-the-loader-59j5</guid>
      <description>&lt;h2&gt;
  
  
  Adding a loading Placeholder
&lt;/h2&gt;

&lt;p&gt;With the current Loader, you can set a placeholder (e.g. a button to trigger the loading) and once it's loaded + created the content of the loader will be switched to the loaded component.&lt;/p&gt;

&lt;p&gt;But what if the connection is slow? (Well .. thats the main goal of this Series 😄, to improve the initial load performance of an angular app 😅) What if the Device is slow? &lt;/p&gt;

&lt;p&gt;You could switch the placeholder content in your host-component (The component that uses the loader and sets the placeholder). But I kinda want to have a simpler way (less duplicate code for all of your host-components.)&lt;/p&gt;

&lt;p&gt;So let's extend the loader with another &lt;code&gt;&amp;lt;ng-content&amp;gt;&lt;/code&gt; which only is visible during the load.&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;ng-content&lt;/span&gt; &lt;span class="na"&gt;*ngIf=&lt;/span&gt;&lt;span class="s"&gt;"componentLoading | async"&lt;/span&gt;
                  &lt;span class="na"&gt;select=&lt;/span&gt;&lt;span class="s"&gt;"[isLoading]"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/ng-content&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;select&lt;/code&gt; here uses an element attribute (&lt;code&gt;isLoading&lt;/code&gt;) to select what has to be projected there.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight typescript"&gt;&lt;code&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="k"&gt;public&lt;/span&gt; &lt;span class="nx"&gt;componentLoading&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="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;code&gt;componentLoading&lt;/code&gt; just emits &lt;code&gt;true&lt;/code&gt;/&lt;code&gt;false&lt;/code&gt; before and after the component is loading. Sadly I needed to add&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;private&lt;/span&gt; &lt;span class="nx"&gt;cd&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;ChangeDetectorRef&lt;/span&gt;

  &lt;span class="c1"&gt;// and&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;cd&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;detectChanges&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;otherwise the &lt;code&gt;EventEmitter&lt;/code&gt; / or rather the template, didn't do anything.&lt;/p&gt;

&lt;p&gt;Example how to use it in your hosting-component:&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;helpers-dynamic-loader&lt;/span&gt; &lt;span class="na"&gt;component=&lt;/span&gt;&lt;span class="s"&gt;"my-own"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  This is a placeholder, while nothing is loading, could also have a button to trigger the load :)

  &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;isLoading&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;mat-progress-spinner&lt;/span&gt; &lt;span class="na"&gt;mode=&lt;/span&gt;&lt;span class="s"&gt;"indeterminate"&lt;/span&gt; &lt;span class="na"&gt;[diameter]=&lt;/span&gt;&lt;span class="s"&gt;"24"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/mat-progress-spinner&amp;gt;&lt;/span&gt;
    Component loading...
  &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/helpers-dynamic-loader&amp;gt;&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;a href="https://gist.github.com/negue/5f4435c7e1d2c11449691d342b39cdd5"&gt;Click here&lt;/a&gt; for the latest version 🎉&lt;/p&gt;

&lt;h3&gt;
  
  
  Current limitations:
&lt;/h3&gt;

&lt;p&gt;The component-loader works fine for custom components, but the lazy-loaded-components can't use any other components. (This weirdly happens without an error).&lt;/p&gt;

&lt;h3&gt;
  
  
  to be (also) done...
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;an example repo (started 🎉) &lt;/li&gt;
&lt;li&gt;maybe export the loader as a bit component? &lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>angular</category>
      <category>lazyloaded</category>
      <category>ivy</category>
      <category>performance</category>
    </item>
    <item>
      <title>Lazy Loaded Components - #2</title>
      <dc:creator>negue</dc:creator>
      <pubDate>Sun, 15 Sep 2019 21:16:16 +0000</pubDate>
      <link>https://dev.to/negue/lazy-loaded-components-2-c7e</link>
      <guid>https://dev.to/negue/lazy-loaded-components-2-c7e</guid>
      <description>&lt;p&gt;Extending the features of the &lt;strong&gt;component-level lazy loader&lt;/strong&gt; thanks to 🎉 Ivy 🎉 &lt;/p&gt;

&lt;p&gt;Continue from Part 1:&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Inject services into lazy-loaded components:
&lt;/h2&gt;

&lt;p&gt;Since the loader uses the same injector-Instance we can inject the same services as the parent Component. &lt;/p&gt;

&lt;p&gt;Side-note: The usual lifecycle callbacks are still working on lazy-loaded components.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. &lt;code&gt;@Input()&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;To set the inputs on the loaded component, the loader uses &lt;code&gt;componentInputs: any&lt;/code&gt; as &lt;code&gt;@Input()&lt;/code&gt;&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;private&lt;/span&gt; &lt;span class="nx"&gt;setInputs&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="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;componentInstance&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&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;componentInputs&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;inputs&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;keys&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;componentInputs&lt;/span&gt;&lt;span class="p"&gt;);&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;const&lt;/span&gt; &lt;span class="nx"&gt;inputKey&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="nx"&gt;inputs&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;componentInstance&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;inputKey&lt;/span&gt;&lt;span class="p"&gt;]&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;componentInputs&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;inputKey&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;code&gt;setInputs&lt;/code&gt; will be called once after the component is created and on each &lt;code&gt;ngOnChanges&lt;/code&gt; that is called for &lt;code&gt;componentInputs&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;Now you can also set inputs to the loaded component 🎉&lt;/p&gt;

&lt;h2&gt;
  
  
  3. &lt;code&gt;@Output()&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;In order to use the outputs of your loaded component, you can just set your callbacks with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight html"&gt;&lt;code&gt;[componentOutputs]="{
 outputName: onYourCallbackMethod
}"
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Since this object is just a dictionary of &lt;code&gt;key: Function&lt;/code&gt;, its rather "easy" to subscribe to the loaded component outputs. 🎉&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;private&lt;/span&gt; &lt;span class="nx"&gt;unsubForOutputs$&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;Subject&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;setOutputs&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;unsubOutputs&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="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;componentInstance&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&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;componentOutputs&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;outputs&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;keys&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;componentOutputs&lt;/span&gt;&lt;span class="p"&gt;);&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;const&lt;/span&gt; &lt;span class="nx"&gt;outputKey&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="nx"&gt;outputs&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="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;componentInstance&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;outputKey&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;emitter&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;componentInstance&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;outputKey&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="k"&gt;as&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;any&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;emitter&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;pipe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
              &lt;span class="nx"&gt;takeUntil&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;unsubForOutputs$&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
            &lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;subscribe&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;componentOutputs&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;outputKey&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="nx"&gt;unsubOutputs&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;unsubForOutputs$&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;next&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;
  
  
  4. Prevent loading the same components multiple times
&lt;/h2&gt;

&lt;p&gt;The prior example had this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;imported&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;DynamicLoaderComponent&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;LazyComponents&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;component&lt;/span&gt;&lt;span class="p"&gt;]();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;That way the requested component would be loaded (HTTP-call) every time.&lt;/p&gt;

&lt;p&gt;To prevent this we can just add a simple cache - object which holds the resolved-promises (in the same way I refactored the registration (again 😅)):&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;DynamicLoaderRegistry&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// Registry&lt;/span&gt;
  &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="nx"&gt;LazyComponents&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="nx"&gt;key&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="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;Promise&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kr"&gt;any&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&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="c1"&gt;// Loaded-Cache&lt;/span&gt;
  &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="nx"&gt;AlreadyLoaded&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="nx"&gt;key&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="nb"&gt;Promise&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kr"&gt;any&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&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="c1"&gt;// cache the promises&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;importComponent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;DynamicLoaderRegistry&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;AlreadyLoaded&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;component&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="nx"&gt;DynamicLoaderRegistry&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;AlreadyLoaded&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;component&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;DynamicLoaderRegistry&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;LazyComponents&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;component&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;imported&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;importComponent&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Now if the same component is requested, its only loaded once 🎉&lt;/p&gt;

&lt;h2&gt;
  
  
  Finalizing the component-loader 🎉 (.. for now 😅)
&lt;/h2&gt;

&lt;p&gt;See: &lt;a href="https://gist.github.com/negue/5f4435c7e1d2c11449691d342b39cdd5/d4a061ca399dc0c3ea0ff7149ffc765c0cbd9dfa"&gt;Current Version&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;to be continued / tried / tested:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;example repo / project&lt;/li&gt;
&lt;li&gt;show that the component is loading&lt;/li&gt;
&lt;li&gt;lazy-loaded module (and one of its components)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Any thoughts / suggestions / ideas ?&lt;/p&gt;

</description>
      <category>angular</category>
      <category>lazyloaded</category>
      <category>ivy</category>
      <category>performance</category>
    </item>
    <item>
      <title>Looking for an in-place markdown editor with highlight</title>
      <dc:creator>negue</dc:creator>
      <pubDate>Thu, 12 Sep 2019 18:09:36 +0000</pubDate>
      <link>https://dev.to/negue/looking-for-an-in-place-markdown-editor-with-highlight-3kih</link>
      <guid>https://dev.to/negue/looking-for-an-in-place-markdown-editor-with-highlight-3kih</guid>
      <description>&lt;p&gt;I've probably wasted many months searching and still haven't found any working (on mobile) markdown editor / web-component.&lt;/p&gt;

&lt;p&gt;I tried:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;codemirror 5 (space-bar somehow closes keyboard on android?!)&lt;/li&gt;
&lt;li&gt;codeflask (weird spacing between normal and highlighted text)&lt;/li&gt;
&lt;li&gt;monaco (sadly doesn't work on mobile)&lt;/li&gt;
&lt;li&gt;probably some more but mostly trying to fix those 3&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;What I'm looking for is simple inline input / web-component, which can highlight markdown-syntax that works on mobile. &lt;/p&gt;

&lt;p&gt;So &lt;code&gt;**bold**&lt;/code&gt; would be highlighted (and maybe also bolded, but still have the asterisks visible).&lt;/p&gt;

&lt;p&gt;I hope somebody here has found / is using some component like this&lt;/p&gt;

</description>
      <category>help</category>
      <category>javascript</category>
      <category>webcomponents</category>
      <category>contenteditable</category>
    </item>
    <item>
      <title>envsure : {dev} en(v)sure packages are installed</title>
      <dc:creator>negue</dc:creator>
      <pubDate>Tue, 10 Sep 2019 18:54:49 +0000</pubDate>
      <link>https://dev.to/negue/envsure-dev-en-v-sure-packages-are-installed-2k16</link>
      <guid>https://dev.to/negue/envsure-dev-en-v-sure-packages-are-installed-2k16</guid>
      <description>&lt;h2&gt;
  
  
  Lets begin at the &lt;em&gt;why&lt;/em&gt;
&lt;/h2&gt;

&lt;p&gt;While using &lt;code&gt;storybook&lt;/code&gt; in &lt;del&gt;a&lt;/del&gt; some projects, I saw the huge amount of packages that needed to be installed by this (dependencies/addons). Sure on a local repo, installing it once this can be ignored. &lt;/p&gt;

&lt;p&gt;But when you push it to your CI and have for example different CI-runners for different kind of tests, you probably don't need to install storybook (and addons) every time for each CI. Well .. maybe one if you want to test your components? But even then only this particular CI-job would need to install the packages.&lt;/p&gt;

&lt;h3&gt;
  
  
  Workaround 1: &lt;code&gt;package.json&lt;/code&gt; (one I used)
&lt;/h3&gt;

&lt;p&gt;You could just create &lt;code&gt;package.json&lt;/code&gt;-script-task, like: &lt;br&gt;
&lt;code&gt;"install-stuff": "npm install myPackage@1 otherPackage@2 andSo@0n"&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This is probably ok for 3-4 packages, but not when having to add like 8+ and having to handle the versions all into one line in your &lt;code&gt;package.json&lt;/code&gt;? I for one don't want to do that (again)&lt;/p&gt;
&lt;h3&gt;
  
  
  Workaround 2: &lt;code&gt;install-other-packages.sh&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;Use the same &lt;code&gt;npm install&lt;/code&gt; in a shell-script, sure you can use multiple lines to ease the overview. &lt;/p&gt;

&lt;p&gt;This would be ok if you have one group of packages you need once but what about different groups ?&lt;/p&gt;
&lt;h3&gt;
  
  
  Workaround 3:
&lt;/h3&gt;

&lt;p&gt;Use a different folder in your repo (which has its own &lt;code&gt;package.json&lt;/code&gt; with these needed packages)&lt;/p&gt;

&lt;p&gt;None of these workarounds were good enough for me. So I just made my own.&lt;/p&gt;
&lt;h2&gt;
  
  
  Introducing &lt;code&gt;envsure&lt;/code&gt; - the unusual (node) package installer addon
&lt;/h2&gt;

&lt;p&gt;You can use &lt;code&gt;envsure&lt;/code&gt; by either having it installed globally &lt;code&gt;npm install -g envsure&lt;/code&gt; or by using &lt;code&gt;npx&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Example: &lt;br&gt;
&lt;code&gt;envsure groupName&lt;/code&gt; or &lt;code&gt;npx envsure groupName&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;It will use the &lt;code&gt;envsure.json&lt;/code&gt; in your current directory to install all needed packages for &lt;code&gt;groupName&lt;/code&gt; without added them to package.json.&lt;br&gt;
&lt;/p&gt;

&lt;div class="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;"version"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"groupName"&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;"packageA"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"1.2.3"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"packageB"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"2.3"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"and-so-on"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"1"&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;&lt;code&gt;version&lt;/code&gt;: (optional) property is used to determine the json schema, in case of future updates. &lt;/p&gt;

&lt;p&gt;Also you could just use it with your usual npm-script&lt;br&gt;
&lt;/p&gt;

&lt;div class="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="nl"&gt;"premy-routine"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"npx envsure groupName"&lt;/span&gt;&lt;span class="err"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
   &lt;/span&gt;&lt;span class="nl"&gt;"my-routine"&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="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;Links: &lt;a href="https://github.com/negue/envsure"&gt;repo&lt;/a&gt; | &lt;a href="https://www.npmjs.com/package/envsure"&gt;npm&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is the first cli I've ever made. So I probably don't have any best-practices on what to use for node-based cli's. Sorry about that! &lt;/p&gt;

&lt;p&gt;Also this is probably just a niche use-case, but maybe it'll help somebody. &lt;/p&gt;

</description>
      <category>showdev</category>
      <category>node</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Performance: Tree-Shake with environment.ts</title>
      <dc:creator>negue</dc:creator>
      <pubDate>Thu, 05 Sep 2019 18:47:31 +0000</pubDate>
      <link>https://dev.to/negue/performance-tree-shake-with-environment-ts-ck3</link>
      <guid>https://dev.to/negue/performance-tree-shake-with-environment-ts-ck3</guid>
      <description>&lt;p&gt;You probably get to the point where you only need modules that has to be there during development but not in the production build.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;p&gt;I use &lt;code&gt;@ngrx/store-devtools&lt;/code&gt; nearly all the time while developing. &lt;/p&gt;

&lt;p&gt;In order to not have this module on my production build, I thought, the solution was &lt;em&gt;easy&lt;/em&gt;-ish, just use the environment-condition to exclude it from the build.&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;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;environment&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;../environments/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;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;StoreDevtoolsModule&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;@ngrx/store-devtools&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;additionalImports&lt;/span&gt; &lt;span class="o"&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;environment&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&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;additionalImports&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;StoreDevtoolsModule&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;instrument&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="na"&gt;maxAge&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;25&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="nd"&gt;NgModule&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;import&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="nx"&gt;additionalImports&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;
app.module.ts





&lt;p&gt;But the compiler still adds the module to production build: about &lt;code&gt;18 kb&lt;/code&gt; added for this module, sure its not "that" much but this adds up to the loading+parsing/eval-time, which you probably don't need.&lt;/p&gt;

&lt;h2&gt;
  
  
  Using &lt;code&gt;environment.ts&lt;/code&gt; the better way :)
&lt;/h2&gt;

&lt;p&gt;Since angular adds a default &lt;code&gt;fileReplacements&lt;/code&gt; config for &lt;code&gt;environment.ts&lt;/code&gt; and &lt;code&gt;environment.prod.ts&lt;/code&gt; those will be only compiled into during development/production build. &lt;/p&gt;

&lt;p&gt;We can also use this to add different modules for our development phase / or to production vice versa.&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;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;StoreDevtoolsModule&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;@ngrx/store-devtools&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;environment&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;production&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;modules&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="nx"&gt;StoreDevtoolsModule&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;instrument&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
      &lt;span class="na"&gt;maxAge&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;25&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;
environment.ts







&lt;div class="highlight"&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;environment&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;../environments/environment&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;import&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="nx"&gt;environment&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;modules&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;
app.module.ts





&lt;h2&gt;
  
  
  🎉 Now that module is only added during development and not in your production build 🎉
&lt;/h2&gt;

&lt;p&gt;Maybe in the future it will be possible to tree-shake these kinds just by using &lt;code&gt;if (environment.production)&lt;/code&gt;, but until then we have a nice workaround. &lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;Protip 1:&lt;/code&gt; Use an interface for your environment files.
&lt;/h3&gt;

&lt;p&gt;Have a &lt;code&gt;environment.def.ts&lt;/code&gt;-File which is something like:&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;Environment&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;production&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="nl"&gt;modules&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;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;That way both (or more?) environments will be at least consistent on the properties.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;Protip 2:&lt;/code&gt; Use a path-alias
&lt;/h3&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="nl"&gt;"compilerOptions"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"paths"&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;"@myApp/env"&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="s2"&gt;"apps/myApp/src/environments/environment"&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;/code&gt;&lt;/pre&gt;&lt;/div&gt;
tsconfig.json





&lt;p&gt;Then you can import your environment in any file just by &lt;code&gt;@myApp/env&lt;/code&gt; instead of &lt;code&gt;../../../..and/so/on../../environment&lt;/code&gt; &lt;/p&gt;





&lt;h3&gt;
  
  
  I really would like to know, if you have/use modules only during dev/prod?
&lt;/h3&gt;

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