<?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: Akshay Mahajan</title>
    <description>The latest articles on DEV Community by Akshay Mahajan (@androizer).</description>
    <link>https://dev.to/androizer</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%2F168494%2Fdb262e37-9696-4f86-9b77-cb3cef7ccb36.jpeg</url>
      <title>DEV Community: Akshay Mahajan</title>
      <link>https://dev.to/androizer</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/androizer"/>
    <language>en</language>
    <item>
      <title>Easy state management in Angular</title>
      <dc:creator>Akshay Mahajan</dc:creator>
      <pubDate>Thu, 21 Apr 2022 14:10:07 +0000</pubDate>
      <link>https://dev.to/androizer/easy-state-management-in-angular-4ln4</link>
      <guid>https://dev.to/androizer/easy-state-management-in-angular-4ln4</guid>
      <description>&lt;p&gt;Angular provides useful feature of services where we encapsulates all our Business Logic (BL) [back-end integration] inside the services. BL does includes persistence of state/data that would probably be meant for other components too. With increased components hierarchy, we tend to increase services that are associated with them which leads to application getting bloated and data communication between services and counter components gets messy.&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fedc2hhr5lobhj8m76ndu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fedc2hhr5lobhj8m76ndu.png" alt="Spaghetti Code"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To fix this problem, we need opinionated state management and vast majority of solutions are already available in OSS market like &lt;code&gt;NgRx, Ngxs, Akita, Elf, RxAngular&lt;/code&gt; etc. But this solution comes with a cost which is their associated learning curve and boilerplate code just to have its initial setup hooked into our application.&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi93qubkkt71oqp6h9oj2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi93qubkkt71oqp6h9oj2.png" alt="I'm Lost"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To reduce this pain and get your system ready up (bare metal) and setup-ed in less time frame, I have created a dead simple state management solution in just less than 50 lines of code.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Yes, you hear it right, its just less than 50 lines of code. 😉&lt;/p&gt;
&lt;/blockquote&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fannq9j5rheg9z1rseevn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fannq9j5rheg9z1rseevn.png" alt="I'm Super happy now"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I'm not gonna say that this is a full fledged state management solution that advanced libraries does. This is a bare metal need of state management which can suffice a need of many developers in their day to day task. For obvious reason when your task and need is more complex, one should consider using an opinionated state management libraries as stated above since they are tested well within the community and are scale-able enough.&lt;/p&gt;

&lt;p&gt;So the basic fundamental of state management is to cache recurring data which is to be passed along a lot of component hierarchy. &lt;a href="https://kentcdodds.com/blog/prop-drilling" rel="noopener noreferrer"&gt;Input/Props drilling&lt;/a&gt; is one the issue where state management methodology like &lt;a href="https://facebook.github.io/flux" rel="noopener noreferrer"&gt;flux&lt;/a&gt; comes to resort. A central global store that will act as hydration of data to our components and probably act as single source to truth for many entities in your application. &lt;/p&gt;

&lt;p&gt;So certain check list needs to be considered when implementing state management that is refer below.&lt;/p&gt;

&lt;p&gt;✅ Central store for most of the entities (single source of truth).&lt;br&gt;
✅ The store should be &lt;strong&gt;reactive&lt;/strong&gt; (pushing instead of polling. Polling can be additional feature too).&lt;br&gt;
✅ Select a certain &lt;strong&gt;slice&lt;/strong&gt; of cached data.&lt;br&gt;
✅ Update/Destroy the cached entity.&lt;br&gt;
✅ No mutation for cached entity outside of &lt;a href="https://redux-toolkit.js.org/usage/usage-guide#writing-reducers" rel="noopener noreferrer"&gt;reducer&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The state management solution that I'm gonna present is &lt;strong&gt;CRUD&lt;/strong&gt; based. And this is gonna suffice 70-80% of use cases.&lt;/p&gt;

&lt;p&gt;The syntax for function wrapper is gonna remind you of slice from &lt;a href="https://redux-toolkit.js.org/api/createSlice" rel="noopener noreferrer"&gt;Redux Toolkit&lt;/a&gt;.&lt;/p&gt;
&lt;h2&gt;
  
  
  Create a wrapper function
&lt;/h2&gt;

&lt;p&gt;We are going to create a wrapper function that will help with the initial implementation of slice.&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;export&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;createSlice&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;opts&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h3&gt;
  
  
  Setting up Initial Data (🇨RUD)
&lt;/h3&gt;

&lt;p&gt;This is the phase where we are going to create a slice with the initial state/data.&lt;/p&gt;

&lt;p&gt;Typings for createSlice Options would look like:&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;export&lt;/span&gt; &lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;CreateSliceOptions&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;T&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;initialValue&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;T&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Using this type inside the function wrapper.&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;export&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;createSlice&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;T&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;opts&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;CreateSliceOptions&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;T&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="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;_value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;opts&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;initalValue&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;
  
  
  Reading the value from inside the slice (C🇷UD)
&lt;/h3&gt;

&lt;p&gt;We need to expose a function from inside the createSlice wrapper that will fetch us the current state inside the slice.&lt;/p&gt;

&lt;p&gt;Typings for createSlice Instance would look like:&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;export&lt;/span&gt; &lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;CreateSliceInstance&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;T&lt;/span&gt;&lt;span class="o"&gt;&amp;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="cm"&gt;/**
  * Returns the current value of slice
  */&lt;/span&gt;
  &lt;span class="na"&gt;getValue&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="nx"&gt;T&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;Using this type inside the function wrapper.&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;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;getValue&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="nx"&gt;_value&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;
  
  
  Updating the data inside of slice (CR🇺D)
&lt;/h3&gt;

&lt;p&gt;In order to update the slice, we will expose a method called &lt;code&gt;update&lt;/code&gt; that will update the value inside the slice.&lt;/p&gt;

&lt;p&gt;Let's add the &lt;code&gt;update&lt;/code&gt; typing to the &lt;code&gt;CreateSliceInstance&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="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;CreateSliceInstance&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;T&lt;/span&gt;&lt;span class="o"&gt;&amp;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="cm"&gt;/**
  * Callback to update the value inside the slice.
  */&lt;/span&gt;
  &lt;span class="na"&gt;update&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="na"&gt;state&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;Partial&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;T&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;void&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;Implementing the update method in the slice wrapper.&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;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;update&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="na"&gt;state&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;Partial&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;T&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="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;_value&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="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;blockquote&gt;
&lt;p&gt;How come this approach would be reactive? How would I subscribe to the changes I performed via &lt;code&gt;update&lt;/code&gt; method?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;In order to make our slice reactive, we need to re-adjust some implementation inside the &lt;code&gt;createSlice&lt;/code&gt; wrapper, but although the typings will remain same.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;NOTE: For now, the implementation only supports objects, and not primitive like string, number, boolean etc.&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;createSlice&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;T&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;opt&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;CreateSliceOptions&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;T&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;CreateSliceType&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;T&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;_ob$&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;BehaviorSubject&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;T&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;_value&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;Proxy&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;opt&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;initialValue&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;set&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;target&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;property&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;receiver&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;allow&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Reflect&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;target&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;property&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;receiver&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="nx"&gt;_ob$&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;next&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;target&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nx"&gt;T&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;allow&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;valueChanges&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;_ob$&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;asObservable&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="nf"&gt;debounceTime&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;)),&lt;/span&gt;
    &lt;span class="na"&gt;getValue&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="nx"&gt;_ob$&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="na"&gt;update&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="na"&gt;state&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;Partial&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;T&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="p"&gt;{&lt;/span&gt;
      &lt;span class="nb"&gt;Object&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;keys&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;_value&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;forEach&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;key&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;state&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;hasOwnProperty&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="p"&gt;{&lt;/span&gt;
          &lt;span class="nx"&gt;_value&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;key&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;key&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="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;WOW, there are a lot of changes. Let's discuss them step-by-step:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;We have created a BehaviorSubject that will emit the value inside it whenever we trigger &lt;code&gt;next&lt;/code&gt; on it.&lt;/li&gt;
&lt;li&gt;Instead of assigning &lt;strong&gt;initalValue&lt;/strong&gt; directly to &lt;code&gt;_value&lt;/code&gt;, we will create a new &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy" rel="noopener noreferrer"&gt;Proxy&lt;/a&gt; object, where we will override various &lt;code&gt;handler&lt;/code&gt; methods on the &lt;code&gt;target&lt;/code&gt; object.
To read more about Proxy Pattern, refer &lt;a href="https://refactoring.guru/design-patterns/proxy" rel="noopener noreferrer"&gt;this&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;We will override the &lt;code&gt;set&lt;/code&gt; method of the target object i.e. &lt;code&gt;initialValue&lt;/code&gt; and will &lt;strong&gt;emit&lt;/strong&gt; an new value, whenever a target is mutated.&lt;/li&gt;
&lt;li&gt;For the &lt;code&gt;update&lt;/code&gt; method, we will iterate over to the properties of the supplied state as param to update method and check if the property key in the state belongs to &lt;strong&gt;initialValue&lt;/strong&gt; object and updating the &lt;code&gt;_value[key]&lt;/code&gt;. The usage of &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwnProperty" rel="noopener noreferrer"&gt;hasOwnProperty&lt;/a&gt; will help us eradicate any miscellaneous (unknown) property from the slice's state.&lt;/li&gt;
&lt;li&gt;We have use &lt;code&gt;debounceTime&lt;/code&gt; in order to aggregate (iteration inside the &lt;code&gt;update&lt;/code&gt; method) the changes in a certain time frame i.e. 100ms and will emit the target finally.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I hope this all makes sense to you all till now.&lt;/p&gt;
&lt;h3&gt;
  
  
  Deleting/Destroying the value inside the slice (CRU🇩)
&lt;/h3&gt;

&lt;p&gt;When the slice is no longer in need, we can simply destroy the slice by calling the &lt;code&gt;destroy&lt;/code&gt; on it.&lt;/p&gt;

&lt;p&gt;Typing and implementation for &lt;code&gt;destroy&lt;/code&gt; would be like:&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="cm"&gt;/**
   * Destroy the slice and closure data associated with it
   */&lt;/span&gt;
  &lt;span class="nx"&gt;destroy&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;void&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;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&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;destroy&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="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;_ob$&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;complete&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
      &lt;span class="c1"&gt;// In case the target reference is used somewhere, we will clear it.&lt;/span&gt;
      &lt;span class="nx"&gt;_ob$&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;next&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;undefined&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="c1"&gt;// Free up internal closure memory&lt;/span&gt;
      &lt;span class="nx"&gt;_value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;undefined&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="nx"&gt;_ob$&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;undefined&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;h3&gt;
  
  
  Resetting the slice's state (with intialValue)
&lt;/h3&gt;

&lt;p&gt;There might be possibility where you might want to reset the state inside the slice.&lt;/p&gt;

&lt;p&gt;Typings and implementation of &lt;code&gt;reset&lt;/code&gt; would be like:&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="cm"&gt;/**
   * Reset the data with initial value
   */&lt;/span&gt;
  &lt;span class="nx"&gt;reset&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;void&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;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&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;reset&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="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;initialValue&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;opt&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="nb"&gt;Object&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;keys&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;initialValue&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;forEach&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;key&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;_value&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="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;initialValue&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="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;h3&gt;
  
  
  Complete Implementation
&lt;/h3&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;



&lt;h3&gt;
  
  
  BONUS
&lt;/h3&gt;

&lt;p&gt;If we see the implementation properly, the mutation can be possible via fetching target value from either &lt;code&gt;getValue&lt;/code&gt; or &lt;code&gt;valueChanges&lt;/code&gt; observable subscription. Although the &lt;strong&gt;mutation should not be happening outside the reducer&lt;/strong&gt; (i.e. inside the slice context only).&lt;/p&gt;

&lt;p&gt;We can fix this behaviour by wrapping the value inside the &lt;code&gt;Object.freeze(target)&lt;/code&gt;. Here is the revised implementation for &lt;code&gt;getValue&lt;/code&gt; and &lt;code&gt;valueChanges&lt;/code&gt; respectively.&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;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;valueChanges&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;_ob$&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;asObservable&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="nf"&gt;debounceTime&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
      &lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;Object&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;freeze&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)),&lt;/span&gt;
  &lt;span class="p"&gt;),&lt;/span&gt;
  &lt;span class="na"&gt;getValue&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;Object&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;freeze&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;_ob$&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="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;
  
  
  Final thoughts
&lt;/h3&gt;

&lt;p&gt;Thanks you for staying till here. You probably have learned something new today and that's a better version of you from yesterday's.&lt;br&gt;
If you like this article, do give it a like or bookmark it for future reference. And if you feel there's need for some improvisation, do let me know in the comments. Would love to learn together.&lt;/p&gt;

</description>
      <category>angular</category>
      <category>observables</category>
      <category>webdev</category>
      <category>typescript</category>
    </item>
    <item>
      <title>Easily consume back-end API's in Angular 4x faster!</title>
      <dc:creator>Akshay Mahajan</dc:creator>
      <pubDate>Tue, 01 Mar 2022 19:48:07 +0000</pubDate>
      <link>https://dev.to/androizer/easily-consume-back-end-apis-in-angular-4x-faster-hpn</link>
      <guid>https://dev.to/androizer/easily-consume-back-end-apis-in-angular-4x-faster-hpn</guid>
      <description>&lt;p&gt;Angular is the web framework of choice for many professional developers. The future development roadmap for angular seems promising and will prevail increasingly high demand in coming years. This is the reason why I'm heavily invested in the angular ecosystem.&lt;/p&gt;

&lt;p&gt;I work as full-stack web developer and developing a feature for the product is highly intensive task and require working on front-end and back-end simultaneously.&lt;/p&gt;

&lt;h2&gt;
  
  
  Actual Problem
&lt;/h2&gt;

&lt;p&gt;Working on back-end with ORM hooks is easy when either its plain old CRUD or with extended Business Logic (BL). But when it comes to consuming API's on front-end, this can be tedious task to write every single API for the back-end. We sure can implement abstract &lt;code&gt;BaseHttpAPIService&lt;/code&gt; and extend it to our services, but support for &lt;em&gt;params&lt;/em&gt;, &lt;em&gt;pathParams&lt;/em&gt;, &lt;em&gt;transformer/adapter&lt;/em&gt; and many other can be tedious and require much planning and can prove to be a a lot of boilerplate.&lt;/p&gt;

&lt;h2&gt;
  
  
  So how do I do it the efficient way?
&lt;/h2&gt;

&lt;p&gt;Well, I have come up with a solution which did helped me in consuming the API's &lt;strong&gt;4x&lt;/strong&gt; faster. The number quantified over here may differ for other's but it surely proved to be right for me.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The solution is based on &lt;strong&gt;&lt;code&gt;Repository&lt;/code&gt;&lt;/strong&gt; pattern with the help of &lt;strong&gt;&lt;code&gt;Entity&lt;/code&gt;&lt;/strong&gt; model.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Let me show you how I did it.&lt;/p&gt;

&lt;h3&gt;
  
  
  Create a Model
&lt;/h3&gt;

&lt;p&gt;I know many of you usually declares model in your project and are on the same page as like me. But still, I would like to show you with some code snippets.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--2_oi9kRT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zpm0x2cefrb7bwe3yrka.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--2_oi9kRT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zpm0x2cefrb7bwe3yrka.png" alt="User Model Definition" width="844" height="710"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Annotate the Model with @Entity decorator
&lt;/h3&gt;

&lt;p&gt;Just a bare simple &lt;code&gt;@Entity&lt;/code&gt; decorator which will have just 1 property (for now) as &lt;code&gt;path&lt;/code&gt; that corresponds to the back-end relative path like &lt;code&gt;/users&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--sde2nV4X--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wjbp5is1ob6x53qvk389.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--sde2nV4X--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wjbp5is1ob6x53qvk389.png" alt="Entity Decorator" width="844" height="824"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Redeem a token for User Repository Service
&lt;/h3&gt;

&lt;p&gt;We injected (via DI) the User Repository Service like we normally do in Angular constructor.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0PoZhW5X--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t32oo0v7ij0gy7rfb90i.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0PoZhW5X--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t32oo0v7ij0gy7rfb90i.png" alt="User Repository Injection" width="880" height="397"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You must be thinking from where the &lt;strong&gt;@Entity&lt;/strong&gt; decorator, &lt;strong&gt;RepoToken&lt;/strong&gt; and &lt;strong&gt;Repository&lt;/strong&gt; came from; Right? Just stay with me, this is going to get excited.&lt;/p&gt;

&lt;h3&gt;
  
  
  Consuming the API in an efficient manner
&lt;/h3&gt;

&lt;p&gt;Since now we have injected the service, we can access the methods of the repository which sounds like &lt;code&gt;findAll, findOne, createOne&lt;/code&gt; etc.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--68n31koP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gdfaofhxyyryprldzzc8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--68n31koP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gdfaofhxyyryprldzzc8.png" alt="Accessing Repository Methods" width="880" height="503"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Shut-up and tell me how to use it now!
&lt;/h3&gt;

&lt;p&gt;Hahahah! Okay! You wanted to know how I did it. I created a library that can help you in doing all this and even more with configurations.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--TAPAACi9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raw.githubusercontent.com/androizer/ngx-crudx/main/crudx-logo.svg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--TAPAACi9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raw.githubusercontent.com/androizer/ngx-crudx/main/crudx-logo.svg" alt="crudx" width="256" height="272"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I have curated 😎 the &lt;a href="https://github.com/androizer/ngx-crudx"&gt;ngx-crudx&lt;/a&gt; library to solve the huddle of consuming the API in angular. Go checkout the library. Below are the list of features currently supported:&lt;/p&gt;

&lt;h3&gt;
  
  
  Features
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Single codebase, yet different Repository for entity. Hence, DRY followed. 😃&lt;/li&gt;
&lt;li&gt;Annotate Entity model with &lt;code&gt;@Entity&lt;/code&gt; decorator to add extra metadata.&lt;/li&gt;
&lt;li&gt;Add support for &lt;strong&gt;Custom Repository&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Support for multiple micro-services &lt;em&gt;(URL bindings)&lt;/em&gt; as multiple connections.&lt;/li&gt;
&lt;li&gt;Ability to &lt;strong&gt;transform&lt;/strong&gt; &lt;a href="https://en.wikipedia.org/wiki/Adapter_pattern"&gt;(Adapter)&lt;/a&gt; &lt;strong&gt;body&lt;/strong&gt; and/or &lt;strong&gt;response payload&lt;/strong&gt; on the fly with easy configuration.&lt;/li&gt;
&lt;li&gt;Engineered an &lt;strong&gt;interceptor&lt;/strong&gt; for query params (both at entity level and as well as individual route level).&lt;/li&gt;
&lt;li&gt;Produced code is performant, flexible, clean and maintainable.&lt;/li&gt;
&lt;li&gt;Follows all possible best practices.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Final Thoughts
&lt;/h2&gt;

&lt;p&gt;The &lt;a href="https://github.com/androizer/ngx-crudx"&gt;ngx-crudx&lt;/a&gt; is amazingly powerful and configurable. If you like the library, give it a star ⭐ which keeps me motivated to build great stuff. If you want to contribute or find any typo/bug, raise an &lt;a href="https://github.com/androizer/ngx-crudx/issues"&gt;Issue&lt;/a&gt; and lets discuss about it.&lt;/p&gt;

&lt;p&gt;Github repository: &lt;a href="https://github.com/androizer/ngx-crudx"&gt;https://github.com/androizer/ngx-crudx&lt;/a&gt;&lt;br&gt;
NPM Package: &lt;a href="https://www.npmjs.com/package/ngx-crudx"&gt;https://www.npmjs.com/package/ngx-crudx&lt;/a&gt;&lt;/p&gt;

</description>
      <category>typescript</category>
      <category>angular</category>
      <category>programming</category>
      <category>repository</category>
    </item>
  </channel>
</rss>
