<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Karim on Medium]]></title>
        <description><![CDATA[Stories by Karim on Medium]]></description>
        <link>https://medium.com/@ackarim?source=rss-889d2fc474dc------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*qKCnCyp5Wldi0qiB.</url>
            <title>Stories by Karim on Medium</title>
            <link>https://medium.com/@ackarim?source=rss-889d2fc474dc------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 15 Nov 2026 05:37:11 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ackarim/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Get your first Ethers in Angular]]></title>
            <link>https://ackarim.medium.com/get-your-first-ethers-in-angular-f8d9a62735ed?source=rss-889d2fc474dc------2</link>
            <guid isPermaLink="false">https://medium.com/p/f8d9a62735ed</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[web3]]></category>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[typescript]]></category>
            <dc:creator><![CDATA[Karim]]></dc:creator>
            <pubDate>Thu, 14 Jul 2022 11:05:50 GMT</pubDate>
            <atom:updated>2022-07-14T11:20:07.618Z</atom:updated>
            <content:encoded><![CDATA[<h4>Angular Dapps for Web3 with Local Hardhat and Metamask</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*RRAHGNOodWsEbeyG_7DJ_g.png" /></figure><p>In this awesome reading we will see a few things, among others:</p><ul><li>An environment for a local node of the Blockchain with Hardhat</li><li>Setting up accounts with Mnemonics or directly with Addresses in Hardhat</li><li>All necessary config for Angular and Web3</li><li>Login UI</li><li>Login with Metamask</li><li>Show the balance in our account</li></ul><h3>Introduction</h3><p>A bunch of tools &amp; frameworks and libraries exists for creating Dapps, however at the time I am writing the article I choose Hardhat and Angular</p><blockquote>Why? Hardhat… Among others</blockquote><p><em>Run Solidity locally</em></p><p><em>Debugging-first</em></p><p><em>Extreme flexibility</em></p><p><em>Fast Development</em></p><p><em>Typescript Integration</em></p><blockquote>Why Angular?</blockquote><ul><li>Awesome framework, not really fashion right now (still wondering why). There are a few nice competitors, however it is still the most complete one allowing you accomplish things others do and also things others can’t.</li><li>Less code, more powerful &amp; scalable and less entropic about plugin and 3º party things</li><li>I agree yee it has a big learning curve but nothing you can’t jump in terms of engineering, I mean anything about landing into the space. 🤔 Maybe, it is a conspiracy to make us believe it is the worst choice…As long as the Google Team is in charge of Angular spending more time in creating and maintaining it, rather than do marketing for me it is ok…</li></ul><h3>Hardhat, Run your own node</h3><h4><strong>Init Hardhat</strong></h4><pre>$mkdir hardhat-tutorial<br>$cd hardhat-tutorial<br>$npm init --yes<br>$npm install --save-dev hardhat<br>$npx hardhat</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/477/1*NcX7JCicr8PvfUMT43FdSg.png" /><figcaption>An interactive cli scaffolding the initial part of your app depending of your needs</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/677/1*AGJCOo5X-TGd20NwSEJ34A.png" /><figcaption>Run a local node of hardhat with $npx hardhat node</figcaption></figure><h4>Metamask network config for Hardhat</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/385/1*wyBINqVpyFtLMeZ6hUKtmA.png" /><figcaption>Add the Hardhat network in Metamask</figcaption></figure><h4>Accounts in Hardhat</h4><p>There are two ways of setting up custom accounts in Hardhat:</p><ul><li><strong>Hardcoding directly accounts</strong></li></ul><p>hardhat.config.js</p><pre>module.exports = {<br>solidity: &quot;0.8.4&quot;,<br>networks: {<br> hardhat: {<br>   accounts:<br>   [<br>    {<br>      privateKey: &#39;0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80&#39;,<br>      balance: &#39;1000000000000000000&#39;<br>    },<br>    {<br>      privateKey: &#39;0xde9be858da4a475276426320d5e9262ecfc3ba460bfac56360bfa6c4c28b4ee0&#39;,<br>      balance: &#39;5000000000000000000&#39;<br>    }<br>  ]</pre><pre>...</pre><p>Note that Ethers are in <a href="https://gwei.io/index.html"><strong><em>Weis</em></strong></a>. Go to the link for further details about the units</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pCOpcVkRDhhnNViYmy2KAQ.png" /><figcaption>2 Accounts with its public keys 🔑 corresponding to private keys 🔐 hardcoded before</figcaption></figure><ul><li><strong>Via Mnemonics a Bip39</strong></li></ul><p>If you have no idea about what I am talking, I share a couple of articles describing these concepts quite well.</p><ul><li><a href="https://coinmarketcap.com/alexandria/glossary/mnemonics">Mnemonics | CoinMarketCap</a></li><li><a href="https://medium.com/coinmonks/official-bip39-word-list-mnemonic-24f170ccfe62">Official BIP39 Word List (mnemonic)</a></li></ul><p>So configuring a <a href="https://hardhat.org/hardhat-runner/docs/config#hd-wallet-config">HD Wallet</a></p><p>hardhat.config.js</p><pre>module.exports = {<br>solidity: &quot;0.8.4&quot;,<br>networks: {<br> hardhat: {<br>   accounts:<br>   {<br>      mnemonic: &quot;test test test test test test test test test test test junk&quot;,<br>     path: &quot;m/44&#39;/60&#39;/0&#39;/0&quot;,<br>     initialIndex: 0,<br>     count: 4,<br>     passphrase: &quot;&quot;<br>   }<br>...</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GsAgGtkIPTByy-P4lWHblg.png" /><figcaption>Now 4 Accounts are created with its public 🔑 and private keys 🔐 alined with seeds and the Bip39 path hardcoded before.</figcaption></figure><p>For further details with custom <a href="https://medium.com/coinmonks/hardhat-configuration-c96415d4fcba">config</a> in hardhat</p><p><a href="https://hardhat.org/hardhat-network#running-stand-alone-in-order-to-support-wallets-and-other-software">Running stand-alone in order to support wallets and other software</a></p><h4>Importing Account in Metamask</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/733/1*F3xh4otueDBuARCXOCjgxA.png" /><figcaption>Take any of these account and copy its private key 🔐</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YfczOEdq4ULSyYhJgBi-lw.png" /><figcaption>Import account with private key 🔐 you copy before</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EeDcAdzW019aF1iY05B7BA.png" /><figcaption>You should see the ETH associated to this account</figcaption></figure><h3>Angular</h3><h4>Create an empty project</h4><pre>$ng new ng-metamask-login</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/876/1*AgQSwnDmuIercLV9bzfWEg.png" /><figcaption>Nothing, amazing here scaffolding via angular-cli</figcaption></figure><h4>Make your Angular App -&gt; Dapp</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/954/1*_uooqfm7F00ROIkJ61pf3w.png" /><figcaption>At the moment I wrote this article, I was working with this version of Angular, etc</figcaption></figure><h4>Dependencies</h4><p>The minimum of libraries we need to interact with our node to make login and web3</p><pre>$npm install ethereumjs-wallet bip39 web3 crypto-js --save</pre><p>Next step, I will go through the most common problems I have found to arrange the project of a Dapp in Angular</p><p><strong>Other Dependencies for a custom ts/webpack config</strong></p><p>Basically, because we would need to make use of node libraries for the Front so we will configure through <a href="https://browserify.org/"><strong><em>browserify</em></strong></a></p><pre>$npm install crypto-browserify stream-browserify stream-http https-browserify os-browserify url --save-dev</pre><p>We need to reconfigure it everything with webpack for building a custom config that works with our bundle</p><p>Allowing dependencies in Js will be the key for integrating those libraries that are already compile to js. A little bit confusing, but this is because they are originally for Node so we must make compatible with our ts project</p><p>angular.json</p><pre>&quot;build&quot;: {</pre><pre>...</pre><pre>&quot;scripts&quot;: [],<br>&quot;allowedCommonJsDependencies&quot;: [<br>    &quot;bip39&quot;,<br>    &quot;crypto-js&quot;,<br>    &quot;ethereumjs-wallet&quot;,<br>    &quot;web3&quot;<br>  ]<br>},</pre><pre>...</pre><p>Configure browserify for loading node libraries</p><p>tsconfig.json</p><pre>&quot;compilerOptions&quot;: {</pre><pre>...</pre><pre>&quot;paths&quot; : {<br>   &quot;crypto&quot;: [&quot;./node_modules/crypto-browserify&quot;],<br>   &quot;stream&quot;: [&quot;./node_modules/stream-browserify&quot;],<br>   &quot;http&quot;: [&quot;./node_modules/stream-http&quot;],<br>   &quot;https&quot;: [&quot;./node_modules/https-browserify&quot;],<br>   &quot;os&quot;: [&quot;./node_modules/os-browserify&quot;],<br>},</pre><pre>...</pre><p>Create an index.d.ts in your src with a wrap of this libraries so you don’t get you app crushed</p><p>index.d.ts</p><pre>declare module &#39;bitcore-mnemonic&#39;;<br>declare module &#39;crypto-js&#39;;</pre><p>Still is crashing, believe me you can try…So last issue, we solve with polyfills</p><p>polyfills.ts</p><pre>...</pre><pre>* APPLICATION IMPORTS<br>*/<br>(window as any).global = window;<br>import { Buffer } from &#39;buffer&#39;;<br>global.Buffer = Buffer;<br>global.process = {<br>env: { DEBUG: undefined },<br>version: &#39;&#39;,<br>nextTick: require(‘next-tick’)<br>} as any;</pre><h4><strong>Angular Dapp</strong></h4><p>Finally, we can develop nice features for our Dapp and everything in a local environment.</p><p>Our goal is login and show our balance. And of course, there are many ways to achieve it, but we divide the puzzle in two pieces:</p><ul><li>Service for interacting with the wallet and web3</li><li>Component containing the login UI and logic for the user to use our Dapp.</li></ul><blockquote><strong>Note</strong>: For the sake of simplicity in this post, I can’t go through all our code in Angular trying to explain every details. However, I share gists leaving all the important feature commented with what we have done in every step so you can find it more understandable</blockquote><p><strong>Web3 Service</strong></p><p><strong><em>Service</em></strong> for wrapping all web3 features and create a little core of all our functionalities</p><p>$ng generate service web3</p><p>Then</p><p>web3.service.ts</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5c04a4d59179ef2da30c1d079b01f8e2/href">https://medium.com/media/5c04a4d59179ef2da30c1d079b01f8e2/href</a></iframe><p>About the <strong>path</strong> you can google &amp; research about Bip39. Anyway, a little bit more info</p><p><a href="https://medium.com/myetherwallet/hd-wallets-and-derivation-paths-explained-865a643c7bf2">HD Wallets and Derivation Paths: Explained</a></p><p><strong>Note</strong>: see <strong><em>getInfo</em></strong> function | For logging purposes, we trace some info like our web3 version, what type of network and all the accounts we set up in hardhat.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Zp4tbamVAfN0WmBKp1NFfg.png" /><figcaption>Debugger, you will see something like</figcaption></figure><p><strong>Note</strong>: see <strong><em>getBalance</em></strong> function | Take care, we should convert from Weis.</p><p>Seeds will be the key for logging into the Dapps so we save &amp; remove them in local storage to make easier our logging. Also, we <strong><em>encrypt</em></strong> and <strong><em>decrypt</em></strong> them avoiding to be easily hacked making of <a href="https://github.com/brix/crypto-js#api"><strong><em>crypto-js</em></strong></a>.</p><p><strong>Login Component</strong></p><p>In our template we create a form, error messages and buttons enabled or disabled depending on some conditions</p><p>login.component.html</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6bc501f2cb761e19a07460ebf5c3af28/href">https://medium.com/media/6bc501f2cb761e19a07460ebf5c3af28/href</a></iframe><p>In our ts we control all the interaction with the user and the platform</p><p>login.component.ts</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6780bab7e613545b8a6cde5d2376dd0d/href">https://medium.com/media/6780bab7e613545b8a6cde5d2376dd0d/href</a></iframe><h3>Result</h3><p>I always try to share onStackblitz or similar, although this time I can’t put hardhat online and locally obviously, it should go to a Testnet.</p><p>So this time I leave some screenshot of the Dapp and the repositories for if you want to run locally in your pc</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/621/1*g0mDvSPdKi6_s2d7cxQNbQ.png" /><figcaption>Landing UI</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/234/1*vTw5A05ggK49Unja90Ul5Q.png" /><figcaption>Incorrectly filled</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/263/1*eQuoKiRgKkJxJWxv04VbZg.png" /><figcaption>Filling correctly the form with enable login</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/570/1*8QZFIfFXZMLosLpMencyVg.png" /><figcaption>After login either with Metamask or Normal login if you put seeds correctly</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/552/1*mndI9sM3nc6eb_BCBZudPQ.png" /><figcaption>After logged with normal login you will need to put the password to entry again, so be careful it must coincide. You can also logout</figcaption></figure><h3>Code</h3><p>I share two github repository with all the code 👨‍💻 I explained before. Just download and follow the instruction (Both in branch feature/login-hardhatlocal).</p><p><a href="https://github.com/ackuser/ng-metamask-login/tree/feature/login-hardhatlocal">GitHub - ackuser/ng-metamask-login at feature/login-hardhatlocal</a></p><p>$npm i</p><p>$npm run start</p><p><a href="https://github.com/ackuser/hardhat-sample/tree/feature/login-hardhatlocal">GitHub - ackuser/hardhat-sample at feature/login-hardhatlocal</a></p><p>$npm i</p><p>$npx hardhat node</p><h3>Next steps</h3><p><em>We will see &amp; learn in this post how to create a local environment of the blockchain to avoid connecting to a Testnet and in this way having all the control about the wallets. Then, we have made a login just to authenticate our wallet and finally we showed the current balance associated to the address.</em></p><p><em>This is the most basic part, we will cover in next chapters how to put our project in a Tesnet, how to process a transaction, something about ERC Tokens a more complex features…</em></p><h3>Conclusion</h3><p>I just share my experience in this new exciting subject, leave your comments if you found it really helpful or if you see any point of improvement. It would be really appreciated.</p><p>Basically we all love scalable projects knowing what we do, better if we can rely on the terminal for automating tasks and simplicity must be a plus so we focus in the solution to solve rather than solving problems for the solution to solve. That’s the reason why I choose Angular &amp; Hardhat, I think it is nice .</p><p>Obviously, some features are only for learning purpose and if you implemented a real one you will take more care security and so on and so forth.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f8d9a62735ed" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Easily test UI components]]></title>
            <link>https://ackarim.medium.com/easily-test-ui-components-fd1d8a03cc54?source=rss-889d2fc474dc------2</link>
            <guid isPermaLink="false">https://medium.com/p/fd1d8a03cc54</guid>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[cypress]]></category>
            <category><![CDATA[testing]]></category>
            <dc:creator><![CDATA[Karim]]></dc:creator>
            <pubDate>Tue, 23 Nov 2021 16:41:39 GMT</pubDate>
            <atom:updated>2021-11-23T16:41:39.781Z</atom:updated>
            <content:encoded><![CDATA[<h4>Accelerate tests with Cypress</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/846/1*tE8vwbwuSAC3wl0aN-QD6A.png" /></figure><p>In the past week, we have already create a component, basically a custom input form component.</p><p>We wish to have everything checked in our new project and quality processes force us to coverage a % of our code with testing, so we have to be ready to test.</p><p>We are bored of boring test for testing functionalities or unit testing that mocks everything in the core of nowhere else, so we decide to use Cypress to be sure things work as we expected they work.</p><p>No comparison and comments vs its predecessors like Selenium, Protactor… It is just faster, very nice to code and it gets the job done.</p><h3>Introduction</h3><p>Summarising, we have to test this component and its different part of the code</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/486/1*KYut4I_suxBxFG5LZ8zh8A.png" /><figcaption>Three states to tests</figcaption></figure><p>If you want to see how we created this custom component, click the link below 👇</p><p><a href="https://ackarim.medium.com/custom-form-elements-in-angular-d3786b0785e9">Custom Form Elements in Angular</a></p><h4>1. Integrating Cypress</h4><pre>ng add @cypress/schematic</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kxiZLVNr_w6blUVFblhVuQ.png" /></figure><h4>2. Think before you make</h4><p>What we are going to test is the three states of the component: Default, Filled and Active.</p><p>Overall, We do focussing on the structure of the data. Then, in terms of the changes we see into the styles and we get deep into what is changed in our Css’s state.</p><p><strong>Default</strong></p><p>We create the component, there is no problem and the component exists in itself with a correct field</p><p><strong>Filled</strong></p><p>We write down into the input and the filled text should appear in the input</p><p><strong>Active</strong></p><p>Changes are reflected in the UI</p><h4>3. Now, testing it with code</h4><p>We build our first tests here</p><p>cypress/integration/spec.ts</p><pre><strong>describe</strong>(&#39;Custom Input Form Component&#39;, () =&gt; {</pre><pre>const typeComponent = &#39;app-text-field-form&#39;</pre><pre><strong>beforeEach</strong>(() =&gt; {<br>  <strong>cy.visit</strong>(&#39;/&#39;)<br>})</pre><p>Just visiting the webpage…</p><p><strong>Default</strong></p><blockquote>We create the component, there is no problem and the component exists in itself with a correct field</blockquote><pre><strong>it</strong>(‘Default’, () =&gt; {<br>  <strong>cy.get</strong>(typeComponent).<strong>contains</strong>(‘Another name’)<br>})</pre><p><strong>Filled</strong></p><blockquote>We write down into the input and the filled text should appear in the input</blockquote><pre><strong>it</strong>(&#39;Filled&#39;, () =&gt; {<br>   const foo = &#39;Hello, World&#39;;<br>   <br>   <strong>cy.get</strong>(typeComponent).<strong>type</strong>(foo)<br>   <strong>cy.get</strong>(`${typeComponent} &gt; input`).<strong>should</strong>(&#39;<strong>have.value</strong>&#39;, foo)<br>})</pre><p><strong>Active</strong></p><blockquote>Changes are reflected in the UI</blockquote><pre><strong>it</strong>(&#39;Active&#39;, () =&gt; {<br>  const foo = &#39;Hello, World&#39;;<br>  <br>  <strong>cy.get</strong>(`${typeComponent} &gt; input`).<strong>first</strong>().<strong>focus</strong>()<br>  <strong>cy.get</strong>(`${typeComponent} &gt; input`).<strong>should</strong>(&#39;<strong>have.css</strong>&#39;, &#39;<strong>border</strong>&#39;, &#39;1px solid rgb(146, 119, 255)&#39;)<br>})</pre><p>In my case, I just compared with the border because it is the only thing to be added when it is Active. However, I admit you can do in a more elegant way adding classes and comparing in Cypress if the classes were added successfully.</p><p>Here is the API of Cypress to interact with the DOM</p><p><a href="https://docs.cypress.io/api/table-of-contents">Table of Contents | Cypress Documentation</a></p><p>Open our tests</p><pre>ng e2e</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6GxN5sA8bE_ekAr__MphMw.gif" /><figcaption>Video generated from Cypress, it is the same you will get if you get the command below run</figcaption></figure><h3>Code</h3><p>I don’t share a Stackblitz because it is hard to integrate with Cypress and you won’t be able to run commands, however I have created a github repository with all the code 👨‍💻 I explained before.</p><p><a href="https://github.com/ackuser/ng-custom-form-input-cypress">GitHub - ackuser/ng-custom-form-input-cypress: Custom Form Input created with Angular and tested with Cypress</a></p><h3>Conclusion</h3><p>If you are newbie in Cypress &amp; testing or even if you didn’t know it, I hope this article can give an idea of the possibilities around Cypress and how it helps us to automate tasks (it comes with a lot of features like video recording, screenshots, etc).</p><p>Nowadays, it is the best Framework for testing Front, this kind of tests give us confidence and allow us to automate interactions.</p><p>There are more capabilities that we may see in other posts, so follow me if you want to see how I solve normal problems that you can find in your daily basis. Stay tuned and see you soon!!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fd1d8a03cc54" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Custom Form Elements in Angular]]></title>
            <link>https://ackarim.medium.com/custom-form-elements-in-angular-d3786b0785e9?source=rss-889d2fc474dc------2</link>
            <guid isPermaLink="false">https://medium.com/p/d3786b0785e9</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[css]]></category>
            <category><![CDATA[typescript]]></category>
            <dc:creator><![CDATA[Karim]]></dc:creator>
            <pubDate>Thu, 18 Nov 2021 17:27:56 GMT</pubDate>
            <atom:updated>2021-11-18T17:27:56.381Z</atom:updated>
            <content:encoded><![CDATA[<h4>Tips to be faster than pre-built Design System or Rich UI libraries</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*31LpfcPdvH_DtRtHxTQadw.png" /></figure><p>Clearly, no one wants boilerplate in its code and there is no need to repeat your code over the time, however sometimes we need to customise components and our first choice is to choose a css framework, a prebuilt design system or a rich ui library.</p><p>But why we don’t create them from scratch? We may create our own component faster and we may reuse in a near future.</p><h3>Introduction</h3><p>We have to create this week for our department…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/356/1*8r4kODzFdjuEZ3uRz4-VeA.png" /></figure><p>Our first thought is to start using Angular Material or Bootstrap…or Maybe Polymer or do a research for a similar web component or another kind of library to cover this form component…</p><p>In this post we will create agnostically, only Angular and our skills styling component</p><h3>Let’s create</h3><h4>1. Generate it</h4><pre>$ ng g c text-field-form</pre><h4>2. Style it</h4><p>There are two elements the input and the descriptive field over the input</p><p>text-form-field.component.html</p><pre>&lt;span class=&quot;field&quot;&gt;Street Address&lt;/span&gt;</pre><pre>&lt;input class=&quot;input&quot; type=&quot;text&quot; /&gt;</pre><p>text-form-field.component.scss</p><pre>@<strong>import</strong> &#39;_fonts&#39;;<br>@<strong>import</strong> &#39;_colors&#39;;</pre><pre>:<strong>host</strong> {<br>    width: 240px;<br>    height: 73px;<br>    display: <strong>flex</strong>;<br>    flex-direction: column;<br>    justify-content: space-around;</pre><pre>.field {<br>    @<strong>include</strong> <strong>font</strong>(12px, medium, 15px, -.25);<br>    color: <strong>$secondary-dark-1</strong>;<br>}</pre><pre>.input {<br>    @<strong>include</strong> <strong>font</strong>(12px, bold, 15px, -.25);<br>    width: 240px;<br>    height: 48px;<br>    border: 1px solid <strong>$secondary-light-1</strong>;<br> }<br>}</pre><p><strong>Tips here:</strong></p><p>★ host: , so you don’t need to create a div wrapping all the elements in html</p><p>★ flex, you gain responsiveness in your components</p><p>★ font, create dry functions with Sass for less code</p><p>★ declare your principal colours as a variables</p><p>And here we are</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/540/1*lc5NTDRY8RU8EdfArkY7XQ.png" /><figcaption>Our development right now</figcaption></figure><p>Mmm wait look when we hover it, bad border and cursor right</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/548/1*2Gd_iA1K8wqFVbQksRlp8g.png" /><figcaption>Blue bordering bothering us and cursor without style</figcaption></figure><p>text-form-field.component.scss</p><pre>...</pre><pre>.input {<br>   @include font(12px, bold, 15px, -.25);<br>   width: 240px;<br>   height: 48px;<br>   border: 1px solid $secondary-light-1;<br>   <strong>border-radius</strong>: 4px;<br>   <strong>caret-color</strong>: $primary-light-1;</pre><pre>   &amp;:focus {<br>      <strong>outline</strong>: none;<br>   }</pre><pre>   &amp;:<strong>hover</strong>, &amp;:<strong>focus</strong> {<br>      border: 1px solid $primary-light-2;<br>   }<br>}</pre><pre>...</pre><p><strong>Tips here:</strong></p><p>★ caret-color and you style the cursor</p><p>★ outline, the you remove the blue border line inherit in all the inputs in html</p><p>★ hover and focus, you will have your border forever</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/516/1*yRmOXtqgh-0JURXRD8OQ-Q.png" /></figure><h4>3. Field name parametizable</h4><p>You can solve this with an <em>@Input</em>, however I see more elegant for spaced and long names to be passed through <strong>ng-content</strong></p><p>text-form-field.component.ts</p><pre>...</pre><pre>control = new FormControl(&#39;&#39;);</pre><pre>...</pre><p>...somewhere.html</p><pre>...</pre><pre>&lt;app-text-field-form&gt;<br>   Another name<br>&lt;/app-text-field-form&gt;</pre><pre>...</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/518/1*WhJZgmATJjjWM12Ycx-22w.png" /><figcaption>Change easily field name with ng-content</figcaption></figure><h4>4. Form Control, make it reactive and valid for Angular Forms</h4><p>Get reactive power in your custom form component just with two lines!!!</p><p>text-form-field.component.ts</p><pre>...</pre><pre>control = new FormControl(&#39;&#39;);</pre><pre>...</pre><p>text-form-field.component.html</p><pre>...</pre><pre>&lt;input class=&quot;input&quot; type=&quot;text&quot; [formControl]=&quot;control&quot; /&gt;</pre><pre>...</pre><h3>Final code</h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fstackblitz.com%2Fedit%2Fangular-ivy-5fbjwm%3Fembed%3D1%26file%3Dsrc%252Fapp%252Ftext-field-form%252Ftext-field-form.component.ts&amp;display_name=StackBlitz&amp;url=https%3A%2F%2Fstackblitz.com%2Fedit%2Fangular-ivy-5fbjwm%3Ffile%3Dsrc%252Fapp%252Ftext-field-form%252Ftext-field-form.component.ts&amp;image=https%3A%2F%2Fc.staticblitz.com%2Fassets%2Fsocial_editor-1e53e71ce7e2963fcef1b44837c4570c3fb10c8cb64b194a6eafa4e145d10edc.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=stackblitz" width="745" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/ed82c4a834e6ee31d394c289e8a0fdfa/href">https://medium.com/media/ed82c4a834e6ee31d394c289e8a0fdfa/href</a></iframe><h3>Next steps</h3><p><em>We will see &amp; learn in another post how to pass the value from the Form Control of the Form Component to its Parent Component, or just pass it like a FormGroup to build a bigger Form outside of it</em></p><h3>Conclusion</h3><p>If you try to build a very customise component with a library half of the times you’ll be faster from scratch.</p><p>Summarising create your own custom things sometimes would be better, I hope you see any tips valid for using in your projects.</p><p>We will cover other interesting topics of Angular soon or better we will show how we create nice thing together solving problems that we find in the way, so stay tuned!!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d3786b0785e9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Design System Fonts in Angular]]></title>
            <link>https://ackarim.medium.com/design-system-fonts-in-angular-103aac29b28f?source=rss-889d2fc474dc------2</link>
            <guid isPermaLink="false">https://medium.com/p/103aac29b28f</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[ux]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[sass]]></category>
            <dc:creator><![CDATA[Karim]]></dc:creator>
            <pubDate>Wed, 17 Nov 2021 12:18:57 GMT</pubDate>
            <atom:updated>2021-11-17T12:18:57.117Z</atom:updated>
            <content:encoded><![CDATA[<h4>A good methodology to fit them using Sass and Google Fonts</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xT3pf-l1b4zlbXgalEEZXA.png" /></figure><blockquote>A nice agile team with the last visual prototype, you are the front developer in charge and you have to build fonts this week for the team.</blockquote><p>I am going to show you how you can accelerate and automise several tasks to achieve this.</p><h3>Introduction</h3><p>Somewhere from UX:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NUY3kwIkzM59cwQGzX_kew.png" /><figcaption>Font descriptions in our System Design</figcaption></figure><p>Spartan will be used as a font and you can find it on Google Fonts</p><p><a href="https://fonts.google.com/?query=spartan">Google Fonts</a></p><p>and here it is</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fB1MofmjNt-86wxN8_b0xQ.png" /></figure><p>If you click on it you will be able to customise several things, but anyway it is very intuitive and easy to use.</p><p>For now we selected medium and bold and also checked. Then, they are ready to copy for our angular project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/314/1*sUU2NQq9g9rE-k8253XhmQ.png" /><figcaption>Note that we use @import to incorporate with Sass</figcaption></figure><h3>Using it</h3><h4>1. Incorporate to your angular project</h4><p>I suppose you are using Sass/Scss if you use Css is quite similar. Another thing is that you are retrieving the font through internet, however it can be downloaded locally for improving time in requests (as a asset).</p><p>style.scss</p><pre>...</pre><pre>@import url(https://medium.com/&#39;https://fonts.googleapis.com/css2?family=Spartan:wght@500;700&amp;display=swap&#39;);</pre><pre>...</pre><h4>2. Modify your angular.json to shortener import</h4><p>angular.json</p><pre>&quot;build&quot;: { // also in &quot;test&quot;: {</pre><pre>...</pre><pre>&quot;styles&quot;: [<br>  &quot;src/styles.scss&quot;<br>],<br><strong>&quot;stylePreprocessorOptions&quot;: {<br>  &quot;includePaths&quot;: [ &quot;src/assets/styles&quot;]<br>},<br></strong>&quot;scripts&quot;: []</pre><pre>...</pre><p>Then, instead of having</p><pre>@import &#39;./../assets/styles/_fonts&#39;;</pre><p>you will have</p><pre>@import &#39;_fonts&#39;;</pre><h4>3. Define the fonts</h4><p>Have a look to one of our fonts</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m3yIvP8Ghb01zJRo-CE0gA.png" /><figcaption>Example of font from our system design, note that I will use h1 as a name don’t confuse with h1 from html</figcaption></figure><p>Using mixin and includes we can achieve a more dry solution</p><p>_fonts.scss</p><pre>@mixin <strong>font</strong>(<br>   $fontSize: medium,<br>   $fontWeight: medium,<br>   $lineHeight: normal,<br>   $letterSpacing: normal<br>) {<br>  font-size: $fontSize;<br>  font-weight: $fontWeight;<br>  font-family: &#39;Spartan&#39;, sans-serif;<br>  line-height: $lineHeight;<br>  letter-spacing: $letterSpacing;<br>}</pre><pre>.<strong>h1</strong> {<br>  @include font(32px, bold, 36px, -1);<br>}</pre><pre>.<strong>h2</strong> {<br>  @include font(20px, bold, 22px, -0.63);<br>}</pre><pre>.<strong>h3</strong> {<br>  @include font(16px, bold, 24px, -0.8);<br>}</pre><pre>.<strong>h3-2</strong> {<br>  @include font(12px, bold, 15px, -0.25);<br>}</pre><pre>.<strong>body1</strong> {<br>  @include font(12px, medium, 15px, -0.25);<br>}</pre><pre>.<strong>body2</strong> {<br>  @include font(11px, medium, 18px, -0.23);<br>}</pre><h4>4. Use it</h4><p>Just apply the class to the element</p><pre>&lt;span class=&quot;<strong>h1</strong>&quot;&gt;<br>     Aliquam porttitor mauris sit amet orci Aenean<br>&lt;/span&gt;</pre><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fstackblitz.com%2Fedit%2Fangular-ivy-yu7xbu%3Fembed%3D1%26file%3Dsrc%252Fassets%252Fstyles%252F_fonts.scss&amp;display_name=StackBlitz&amp;url=https%3A%2F%2Fstackblitz.com%2Fedit%2Fangular-ivy-yu7xbu%3Ffile%3Dsrc%252Fassets%252Fstyles%252F_fonts.scss&amp;image=https%3A%2F%2Fc.staticblitz.com%2Fassets%2Fsocial_editor-1e53e71ce7e2963fcef1b44837c4570c3fb10c8cb64b194a6eafa4e145d10edc.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=stackblitz" width="745" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/eb5e32d18cee949f9698cba249a83ed7/href">https://medium.com/media/eb5e32d18cee949f9698cba249a83ed7/href</a></iframe><h3>Conclusion</h3><p>I hope I was able to show you the basics of the workflow between a Design System and Front (implementing the Font part relatively easy).</p><p>Also, the importance of having a good UX prototype and how you can reduce your code drastically using Angular and Sass.</p><p>It would be really nice to know how others achieve this kind of tasks in Angular or if there are other nice solutions.</p><p>Anyway, we will cover other interesting topics of Angular soon, so stay tuned!!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=103aac29b28f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Angular default pipes and i18n]]></title>
            <link>https://ackarim.medium.com/angular-default-pipes-and-i18n-ff6d1bd2627a?source=rss-889d2fc474dc------2</link>
            <guid isPermaLink="false">https://medium.com/p/ff6d1bd2627a</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[front-end-development]]></category>
            <dc:creator><![CDATA[Karim]]></dc:creator>
            <pubDate>Wed, 10 Nov 2021 13:36:14 GMT</pubDate>
            <atom:updated>2021-11-10T13:36:14.286Z</atom:updated>
            <content:encoded><![CDATA[<h4>Euro currency with European format</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j5Yh2hm_nnWKeQ5nMAAPGg.png" /><figcaption>Angular pipe to convert currency to eurs with Spanish format</figcaption></figure><p>Sometimes you need to format your template and you don’t want to bother your back end, neither your services in the front end part.</p><p>Predefined <strong>Pipes</strong> are a really good options for fitting your necessities in this case.</p><p>You may already know, but if not you must know that there are already exists some default pipes built in Angular</p><p><a href="https://angular.io/guide/pipes#transforming-data-using-pipes">Angular</a></p><h3>Introduction</h3><p>The other day I was working in a project in which we have to show currency like X.XXX.XXX,XXX € -&gt; i.e 1.989.674,123 €</p><p>Very basic, but interesting for new people learning Angular or for anyone who doesn’t already know how to do it.</p><p>And I will teach you how I solve it without touching any code neither in your logic (ts) or services in Front, nor in the Back. Therefore, leave you number &amp; figures to travel along ...</p><h3>i18n</h3><blockquote>In computing, internationalization and localization, often abbreviated as i18n means of adapting computer software to different languages, regional peculiarities and technical requirements of a target locale. Internationalization is the process of designing a software application so that it can be adapted to various languages and regions without engineering changes. Localization is the process of adapting internationalized software for a specific region or language by translating text and adding locale-specific components…</blockquote><h3>Code</h3><p>First of all, for the sake of simplicity we are going to use an already built in pipe to convert our amounts in €</p><p>src/app/app.component.html</p><pre>{{ amount | currency: &#39;EUR&#39; }}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/112/1*fU3jqUt_QWkLvtfMEmqIyA.png" /><figcaption>Our currency converted to Euros</figcaption></figure><p>But, what about if I want to say eyy I am for example in Spain so you should show that like if I were there …</p><p>src/app/app.module.ts (I do globally)</p><pre>...</pre><pre>import { registerLocaleData } from &#39;@angular/common&#39;;<br>import localeEs from &#39;@angular/common/locales/es&#39;;<br>registerLocaleData(localeEs);</pre><pre>...</pre><pre>providers: [<br>  {<br>    provide: LOCALE_ID,<br>    useValue: &#39;es-ES&#39;,<br>  },<br>],</pre><pre>...</pre><p>That’s were the magic occurs behind the pipe, for more info about registerLocaleData and so on you can browse trough <a href="https://angular.io/api/common/registerLocaleData">https://angular.io/api/common/registerLocaleData</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/125/1*69W1J76tOWmd_GBL6shapA.png" /><figcaption>Our currency converted to Euros with correct format in Spain</figcaption></figure><p>I leave this little code here, so you can play with it …</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fstackblitz.com%2Fedit%2Fangular-ivy-iapukk%3Fembed%3D1%26file%3Dsrc%252Fapp%252Fapp.module.ts&amp;display_name=StackBlitz&amp;url=https%3A%2F%2Fstackblitz.com%2Fedit%2Fangular-ivy-iapukk%3Ffile%3Dsrc%252Fapp%252Fapp.module.ts&amp;image=https%3A%2F%2Fc.staticblitz.com%2Fassets%2Fsocial_editor-1e53e71ce7e2963fcef1b44837c4570c3fb10c8cb64b194a6eafa4e145d10edc.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=stackblitz" width="745" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/b46d2fa751b860dbe61e620ed7546482/href">https://medium.com/media/b46d2fa751b860dbe61e620ed7546482/href</a></iframe><h3>Conclusions</h3><p>Pipes are a good approach to leave your template cleaners, helping us to separate a lot of logic inside them.</p><p>With i18n we can see how powerful your code can be working contextually depending on your location.</p><p>There are for sure so many ways to achieve that, however I thought it was very interesting to target it from the point of view of i18n and pipes.</p><p>Stay on touch, we will see more examples to reduce your code and make your apps more adaptive for your users.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ff6d1bd2627a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Great Designs deserves Excellent Developments]]></title>
            <link>https://ackarim.medium.com/great-designs-deserves-excellent-developments-f05327014567?source=rss-889d2fc474dc------2</link>
            <guid isPermaLink="false">https://medium.com/p/f05327014567</guid>
            <category><![CDATA[css]]></category>
            <category><![CDATA[web-design]]></category>
            <category><![CDATA[sketch]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[angular]]></category>
            <dc:creator><![CDATA[Karim]]></dc:creator>
            <pubDate>Tue, 23 Mar 2021 17:23:12 GMT</pubDate>
            <atom:updated>2021-03-23T17:23:12.334Z</atom:updated>
            <content:encoded><![CDATA[<h4>Fit your Sketch designs with Angular more Grid &amp; Flexbox</h4><p>In terms of development precise, meticulous and scrupulous doesn’t mean perfect, but almost. We normally start from something like</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/784/1*cniV4xLVZFhHqwMignsiPw.png" /><figcaption>Screenshot of Sketch Design we have to develop</figcaption></figure><p>So imagine you receive a Sketch file, should I do exactly as the design is? Well, if it is a great design deserves to do pixel by pixel.</p><p>I am going to summarise as much as I can some approach and methodologies for you to achieve development products that match visually and aesthetically in a 99% its designs…and of course with my favourite framework, Angular.</p><p>Have a look to that 👇</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*szeRxsORb3oQDLk7uFer3g.gif" /><figcaption>Design vs Solution in Development, almost identical</figcaption></figure><h3>Theory</h3><p>Maybe very clear for some people, but very unknown for many others</p><p><a href="https://www.designsystems.com/space-grids-and-layouts/"><strong>Layouts</strong></a> are the culmination of defined spatial rules and the organisation of content into one single composition. Bringing together your content into thoughtful structures is the easy part, making it all flow together with a clear hierarchy across a sea of changing platforms and screen sizes is the hard part…</p><p><a href="https://www.flux-academy.com/blog/why-is-layout-important-in-graphic-design"><strong>Grids</strong></a> are useful in layout design because they help structure and <a href="https://medium.com/manabie/grid-layout-in-design-7c462a9b44d0">organise</a> content. Although grids are invisible in the user-facing design, it’s easy to tell at a glance whether a layout follows a grid system…</p><p>The foremost purpose of a grid — in graphic design at least — is to establish a set of guidelines for how elements should be positioned within a layout. Not only does an effective grid provide the rhythm for a design, but it also defines the meter.</p><p>Here a couple of links pointing to an interesting post for having quick look about the <a href="https://trydesignlab.com/blog/grids-ui-ux-graphic-design-quick-history-5-amazing-tips/">history</a> behind and another one talking to some concepts regarding to <a href="https://www.designsystems.com/space-grids-and-layouts/">spatial system</a>, grid and layouts</p><h3>In practice</h3><h4>Sketch</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/568/1*6CCwh4NxGmJ9ml4Z2T6_iQ@2x.gif" /><figcaption>Layout Settings in Sketch</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/568/1*KOY_APDeW0d0_RCb35wMWw@2x.gif" /><figcaption>Grid Settings in Sketch</figcaption></figure><h4>Development</h4><blockquote><em>The persistence of grid-based design in web and app design has also been a challenge for developers shaping web standards. In the early days of the web, developers often used tables to organise a layout. Since then, standards have evolved and we now have systems like </em><a href="https://medium.freecodecamp.org/an-animated-guide-to-flexbox-d280cf6afc35"><em>Flexbox</em></a><em> and </em><a href="https://medium.freecodecamp.org/learn-css-grid-in-5-minutes-f582e87b1228"><em>CSS Grid</em></a><em> which offer a basic framework for faithfully implementing grid systems in websites and apps.</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/382/1*AjphUuZk6tdFJekdiLbhMA.png" /><figcaption><strong>You could think of flexbox as “one dimensional.”</strong> While flexbox can make rows and columns in the sense that it allows elements to wrap, there’s no way to declaratively control where elements end up since the elements merely push along a single axis and then wrap or not wrap accordingly. They do as they do, if you will, along a one-dimensional plane and it’s because of that single dimension that we can optionally do things, like align elements along a baseline — which is something grid is unable to do.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*AJ751E_ysEqOD2Y3tnAOeQ.png" /><figcaption><strong>You could think of grid as “two dimensional“</strong> in that we can (if we want to) declare the sizing of rows and columns and then explicitly place things into both rows and columns as we choose.</figcaption></figure><blockquote>Grid is mostly defined <strong>on the parent element</strong>. In flexbox, most of the layout (beyond the very basics) happen <strong>on the children</strong>.</blockquote><p>Nice article to read</p><p><a href="https://css-tricks.com/quick-whats-the-difference-between-flexbox-and-grid/">https://css-tricks.com/quick-whats-the-difference-between-flexbox-and-grid/</a></p><p>Now, we can build whatever Responsive Layout / Grid for apps with those tools.</p><p>There are already some very nice built-in frameworks / libraries defining Responsive Layout Grid like <a href="https://material.io/design/layout/responsive-layout-grid.html">Material Design</a> or <a href="https://getbootstrap.com/docs/4.0/layout/grid/">Bootstrap</a>.</p><p>However, I encourage you to build a custom one deciding what is better for the project with your UX colleagues</p><h3>Challenge cases, all pieces together…</h3><h4>Defining Layouts in Sass</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/798/1*zf1_K0sjbUYFIlvZBxsEZw.png" /><figcaption>Layout in Sketch</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/826/1*g6Sjc2Y0SRIZpXH-0uSVWA.png" /><figcaption>Variables for Layout with Sketch</figcaption></figure><p>How is the code?</p><p>Using <a href="https://css-tricks.com/snippets/css/complete-guide-grid/"><strong>Grid</strong></a><strong> </strong>(yes, grid in development; layout in designs)</p><p>src/assets/styles/_layout.scss</p><pre>// Layout System in Large Devices</pre><pre>$layout-column-width-lg: 94px;<br>$layout-gutter-width-lg: 28px;</pre><p>app.component.scss</p><pre>@import &#39;_layout&#39;;</pre><pre>@media screen and (min-width: 1024px) {</pre><pre>column-gap: $layout-gutter-width-lg;</pre><pre>grid-template-columns: repeat(12, $layout-column-width-lg);</pre><pre>grid-template-rows: 534px 266px;</pre><pre>grid-template-areas:</pre><pre>&quot;area-1 area-1 area-1 area-1 area-1 area-1 area-1 area-2 area-2 area-2 area-2 area-2&quot;</pre><pre>&quot;area-3 area-3 area-3 area-3 area-4 area-4 area-4 area-4 area-5 area-5 area-5 area-5&quot;;</pre><pre>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gkr-Do02y8Gb0TZt3DQZYQ.png" /><figcaption>Our Development in Firefox with Inspector Dev Tools showing us our Layout System</figcaption></figure><p>We just cover the position in the parent element, the code can change a little but the philosophy is the same</p><h4>Defining Grids in Sass</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/782/1*j9RwjafFfIoDohf42gzx0Q.png" /><figcaption>Grid in Sketchs</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/792/1*FEEHG7vKGL6lGvt1SEaEkA.png" /><figcaption>Variables for Grid with Sketch</figcaption></figure><p>src/assets/styles/_grid.scss</p><pre>// Grid System in Large Devices</pre><pre>$grid-cell-lg: 16px;<br>$grid-block-lg: 10 * $grid-cell-lg;</pre><p>Now, zooming</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/207/1*jHFDKgueqbj8i7BFPpnf0g.png" /><figcaption>Logo</figcaption></figure><p>app.component.scss</p><pre>...</pre><pre>.img {<br>    &amp;--logo {<br>       position: absolute;<br>       left: 0;<br>       right: 0;</pre><pre>...</pre><pre>       @media screen and (min-width: 1024px) {</pre><pre>          margin-top: $grid-cell-lg * 4;<br>          margin-left: $grid-cell-lg * 4;</pre><pre>        }<br>}</pre><p>The point here is that we are now able to put every single piece of the design in the correct place</p><h4>Flexbox</h4><p>Yes, <a href="https://css-tricks.com/snippets/css/a-guide-to-flexbox/">flexbox</a> for everything else like …</p><p>For example</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/477/1*v9l2YZMqou0j067PfPGvzA.png" /><figcaption>Menu and its width</figcaption></figure><p>menu.component.html</p><pre>...</pre><pre>&lt;div class=&quot;menu&quot;&gt;<br>    &lt;span class=&quot;item&quot;&gt;home&lt;/span&gt;<br>    &lt;span class=&quot;item&quot;&gt;shop&lt;/span&gt;<br>    &lt;span class=&quot;item&quot;&gt;about&lt;/span&gt;<br>    &lt;span class=&quot;item&quot;&gt;contact&lt;/span&gt;<br>&lt;/div&gt;</pre><p>menu.component.scss</p><pre>...</pre><pre>width: 243px;<br>display: flex;<br>justify-content: space-between;</pre><pre>...</pre><p>I will leave you here the repo on GitHub</p><p><a href="https://github.com/ackuser/nx-room-homepage/tree/develop">ackuser/nx-room-homepage</a></p><p>and the link to the site</p><p><a href="https://nx-room-homepage.vercel.app/">Frontend Mentor | Room homepage</a></p><p>just in case you want to have a deeper look</p><h3>✍ Conclusion ✍</h3><p>Support your developments with <strong>Layout</strong>, <strong>Grid</strong> over your <strong>design</strong> and <strong>using</strong> <strong>Css</strong>/<strong>Sass</strong> with <strong>Grid</strong> and <strong>Flexbox</strong> in <strong>Angular</strong> is the best option to me to make 1 to 1 pixel from Design to Development.</p><p>This <a href="https://www.frontendmentor.io/challenges/room-homepage-BtdBY_ENq"><strong>design &amp; challenge</strong></a> was taken from <strong><em>Frontend Mentor</em></strong> is such a <strong><em>great place</em></strong> to make yourself grow up professionally by allow you to <strong><em>improve your skills </em></strong><em>practising development</em>.</p><h3>👣 Next Steps 👣</h3><p>This post helps me to show you how I solved part of the challenge. In next <strong><em>posts</em></strong> we will see other things related with Angular and other problems so stay tuned!!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f05327014567" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Angular NX and Vercel]]></title>
            <link>https://ackarim.medium.com/angular-nx-and-vercel-2ac3e2035e53?source=rss-889d2fc474dc------2</link>
            <guid isPermaLink="false">https://medium.com/p/2ac3e2035e53</guid>
            <category><![CDATA[vercel]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[nx]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[angular]]></category>
            <dc:creator><![CDATA[Karim]]></dc:creator>
            <pubDate>Tue, 23 Mar 2021 09:58:45 GMT</pubDate>
            <atom:updated>2021-03-23T09:58:45.839Z</atom:updated>
            <content:encoded><![CDATA[<h4>A DevOp day deploying Nx Angular monorepos through Vercel</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fk_LN5AbJeHxIylgQYGvBA.png" /></figure><p><a href="https://nx.dev/">Nx</a> is like a kind of framework for creating modern projects, its app skeleton is similar to a mono-repository. There, you can have your Front and Back end and shared all your interfaces and classes between them, that one of the top benefit I saw</p><h4>Introduction</h4><p>For the case of Angular monorepo for Front, among other features it comes with <a href="https://jestjs.io/">Jest</a>, <a href="https://www.cypress.io/">Cypress</a> and <a href="https://eslint.org/">EsLint</a> by default, so it has been my favourite choice for creating new project in Angular.</p><p>Have a look to these links if you have no idea about what I am talking about</p><ul><li><a href="https://nx.dev/">Nx: Smart Repos · Fast Builds</a></li><li><a href="https://indepth.dev/posts/1247/code-sharing-made-easy-in-a-full-stack-app-with-nx-angular-and-nestjs">Code-sharing made easy in a full-stack app with Nx, Angular, and NestJS - Angular inDepth</a></li></ul><p>Another thing I found in the last days was <a href="https://vercel.com/">Vercel</a>, a great platform for deploying software. You will be able to import your git repository and deploy instantaneously your product, once the pipeline has already finished successfully.</p><p><a href="https://vercel.com/">Agentic Infrastructure - Vercel</a></p><h4>Problem</h4><p>You can choose a lot of frameworks to deploy in Vercel, however there is no exists one a choice for Nx</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/763/1*pBCbDh8QhMORQ6DgLE9niQ.png" /><figcaption>Project Name</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/847/1*e5nI6IZiWH6pv_aAHP6b3w.png" /><figcaption>Connect your git repository</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/675/1*2pTV2u-jSoNJDQ-whEwsxg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/598/1*YOKN9ombPiQ1NZ7umwSSqw.png" /><figcaption>Options for choosing the framework</figcaption></figure><h4>Solution</h4><p>I found a way to do that, so I will put and share here my config just in case you are in a similar situation</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/761/1*uHyjG2aeNDBcF-NkpTp9aQ.png" /><figcaption>In Project Settings choose <strong>Other</strong> for Nx and Angular</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/827/1*2iXspiYlh530gs8_Oxhn1g.png" /><figcaption>Leave this with the default options</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/846/1*NOUKATXqUp-r0q_y2vNjmw.png" /><figcaption>Deployments</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/543/1*U0Rovm0MUnC0aWeQjC-jcg.png" /><figcaption>Logs</figcaption></figure><p>Just if you want to see the site</p><p><a href="https://nx-room-homepage.vercel.app/">https://nx-room-homepage.vercel.app/</a></p><h4>✍ Conclusion ✍</h4><p>We see a new stack for you to show all the magic behind your full stack powers ;)</p><p>I will keep me up to date with Nx since it is gaining more space in this huge universe of techs that are appearing everyday.</p><p>Also, my first experience with Vercel that I have known through <a href="https://www.frontendmentor.io/">Frontend Mentor</a> was very nice. Basically, it is so easy and fast for deploying basic projects and also for free.</p><p>I hope this article can give you fresh ideas for exploring new worlds in web development to make your days easier</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2ac3e2035e53" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Bubble Chart in D3js]]></title>
            <link>https://medium.com/analytics-vidhya/bubble-chart-d3js-c1dfc01bae86?source=rss-889d2fc474dc------2</link>
            <guid isPermaLink="false">https://medium.com/p/c1dfc01bae86</guid>
            <category><![CDATA[d3js]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[data-visualization]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[svg]]></category>
            <dc:creator><![CDATA[Karim]]></dc:creator>
            <pubDate>Tue, 01 Sep 2020 18:48:41 GMT</pubDate>
            <atom:updated>2020-09-05T16:57:08.731Z</atom:updated>
            <content:encoded><![CDATA[<p>Understanding a chart with d3 v6</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/660/0*0XnVU5NNCHJUQ7KX.jpg" /></figure><p>D3js is human readable sometimes, however in certain occasions you see a chart you want to create or just copy from somewhere else and</p><p>In this post, we will see a tutorial for basic bubble chart that may help you. To be honest, it is a tutorial also for myself. In the past few years, I have done like ten bubble charts and every time I start from scratch.</p><h4>Introduction</h4><p>First question, what is Bubble Chart…</p><blockquote><em>A scatterplot with variable dot size</em></blockquote><p>from <a href="https://www.data-to-viz.com/">https://www.data-to-viz.com/</a> which is an amazing, fantastic and awesome resource that you should have a look if you are starting with DataViz (either has content with Python or R)</p><p>How a bubble chart looks like</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/506/1*iOMMQVmyhuE-DsFsh2Iz_A.png" /><figcaption>From Wikipedia, a bubble chart show the relationship between three variables.</figcaption></figure><h4>Version 6</h4><p>Why 6?</p><p>At this time is the latest stable version of d3. To me it is more compacted, you have more functions in its core and is easier to load its modules…</p><p>I leave you the link anyway for installing it in different environments</p><p><a href="https://github.com/d3/d3#installing">https://github.com/d3/d3#installing</a></p><p>But, I love npm so if you are like me …</p><pre>$ npm i d3</pre><p>Then, in you load in your js</p><p>index.js</p><pre>import * as d3 from &quot;d3&quot;;</pre><h4>Dataset</h4><p>We are going to create something similar, now imagine you have a similar dataset</p><pre>const dataset = [<br>{ type: &quot;Sample 1&quot;, value: 50, radius: 7 },<br>{ type: &quot;Sample 2&quot;, value: 30, radius: 11 },<br>{ type: &quot;Sample 3&quot;, value: 10, radius: 3 }<br>];</pre><p>But, first of all a couple of utility function in d3 to manipulate data</p><p>d3.extent to calculate min and max</p><pre><strong>d3.extent</strong>(dataset, d =&gt; d.value) ==&gt; <em>[10, 50]</em></pre><p>However, our Y Axis starts at 0 so we can only use d3.max function and finish with 60.</p><pre><strong>d3.max</strong>(dataset, d =&gt; d.value) + 10 ==&gt; <em>60</em></pre><p>Moreover, we need an array with all the ordinal values so we can use map function from es6 or mapping from d3 that extracts the names.</p><pre>dataset.<strong>map</strong>(d =&gt; d.type) ==&gt; <em>[&quot;Sample 1&quot;, &quot;Sample 2&quot;, &quot;Sample 3&quot;]</em></pre><pre>d3.map(dataset, d =&gt; d.type).keys() ==&gt; <em>[&quot;Sample 1&quot;, &quot;Sample 2&quot;, &quot;Sample 3&quot;]</em></pre><p>As you see d3 has some native functions over arrays that can be very useful.</p><h4>Svg</h4><p>It is always the same, create a frame with margin, the width &amp; height of the content, translating it correctly to visually /display correctly and so on and so forth…</p><p>index.html</p><pre>&lt;div id=&quot;<strong>viz</strong>&quot;&gt;&lt;/div&gt;</pre><p>index.js</p><pre>const <strong>margin</strong> = { top: 40, right: 150, bottom: 60, left: 30 },<br><strong>width</strong> = 500 - margin.left - margin.right,<br><strong>height</strong> = 420 - margin.top - margin.bottom;</pre><pre>const svg = d3<br>.select(&quot;<strong>#viz</strong>&quot;)<br>.append(&quot;<strong>svg</strong>&quot;)<br>.attr(&quot;width&quot;, width + margin.left + margin.right)<br>.attr(&quot;height&quot;, height + margin.top + margin.bottom)<br>.append(&quot;g&quot;)<br>.attr(&quot;transform&quot;, &quot;translate(&quot; + margin.left + &quot;,&quot; + margin.top + &quot;)&quot;);</pre><h4>Axis and Scale</h4><p>For X Axis we have to create and scale of discrete values equally distributed along the axis</p><p>index.js</p><pre>const types = dataset.map(d =&gt; d.type); ==&gt; <em>[&quot;Sample 1&quot;, &quot;Sample 2&quot;, &quot;Sample 3&quot;]</em></pre><pre>// Add X scale</pre><pre>const x = d3<br>.<strong>scaleBand</strong>()<br>.domain(types)<br>.range([0, width]);</pre><pre>// Add X axis</pre><pre>svg<br>.append(&quot;g&quot;)<br>.attr(&quot;transform&quot;, &quot;translate(0,&quot; + height + &quot;)&quot;)<br>.call(d3.<strong>axisBottom</strong>(x));</pre><p>At this point, you may wonder why I use scaleBand rather than scaleOrdinal ???</p><blockquote>scaleOrdinal maps discrete values (specified by an array) to discrete values (also specified by an array)</blockquote><p>And</p><blockquote>In scaleBand domain is specified as an array of values (one value for each band) and the range is splitted automatically into <em>n</em> bands computing the positions and widths of them.</blockquote><p>So basically with scaleBand we specify less and we get part of the job done automatically</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/432/1*PYVc38FJ1ebVcMNW7xD42A.png" /><figcaption>X Axis and X Scale that we have created with the code below</figcaption></figure><p>For understanding scales, another amazing resource is</p><p><a href="https://www.d3indepth.com/scales/">https://www.d3indepth.com/scales/</a></p><p>For Y Axis we create a linear scale from 0 to the maximum value of values</p><p>index.js</p><pre>const yMax = d3.max(dataset, d =&gt; d.value) + 10 ==&gt; <em>60</em></pre><pre>// Add Y scale</pre><pre>const y = d3<br>.<strong>scaleLinear</strong>()<br>.domain([0, yMax])<br>.range([height, 0]);</pre><pre>// Add Y axis</pre><pre>svg.append(&quot;g&quot;).call(d3.<strong>axisLeft</strong>(y));</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/448/1*c_BgXxO_rYsYQA_gZEsSGQ.png" /><figcaption>Axis and Scales that we have created with the code below</figcaption></figure><h4>Bubbles</h4><p>For Bubbles we create circles using radius value in dataset for size and positioning them with its type and value. Normally, things used to be more complex with a customized scale in radius and colorized bubbles.</p><p>index.js</p><pre>// Add bubbles</pre><pre>svg<br>.append(&quot;g&quot;)<br>.selectAll(&quot;bubble&quot;)<br>.data(dataset)<br>.enter()<br>.append(&quot;circle&quot;)<br>.attr(&quot;<strong>cx</strong>&quot;, d =&gt; x(d.type) + 50)<br>.attr(&quot;<strong>cy</strong>&quot;, d =&gt; y(d.value))<br>.attr(&quot;<strong>r</strong>&quot;, d =&gt; d.radius)<br>.style(&quot;fill&quot;, &quot;lightcyan&quot;)<br>.style(&quot;opacity&quot;, &quot;0.7&quot;)<br>.attr(&quot;stroke&quot;, &quot;black&quot;);</pre><h4>Result</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/453/1*tI3-Uuha4lnmDoGdKxlynQ.png" /><figcaption>Here it is our basic Bubble Chart</figcaption></figure><h4>Code</h4><p><a href="https://github.com/ackuser/d3js-bubble-chart">ackuser/d3js-bubble-chart</a></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fstackblitz.com%2Fedit%2Fd3js-bubble-chart%3Fembed%3D1%26file%3Dindex.js&amp;display_name=StackBlitz&amp;url=https%3A%2F%2Fstackblitz.com%2Fedit%2Fd3js-bubble-chart%3Ffile%3Dindex.js&amp;image=https%3A%2F%2Fc.staticblitz.com%2Fassets%2Ficon-03bbb9acbba813917725387f46e5df03a95d232be240e910ce5f946a973b3f86.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=stackblitz" width="745" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/afa764c1231754f62b43590d3bdeea68/href">https://medium.com/media/afa764c1231754f62b43590d3bdeea68/href</a></iframe><h4>Conclusions</h4><p>You can play with it, changing a lot of things and customize colors, axis, etc.</p><p>If you start with dataviz and d3js, try to go deeper understanding every thing you do. It is a hard task at the beginning, but there are a lot of resources and step by step you can do amazing things.</p><p>Thanks for reading.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c1dfc01bae86" width="1" height="1" alt=""><hr><p><a href="https://medium.com/analytics-vidhya/bubble-chart-d3js-c1dfc01bae86">Bubble Chart in D3js</a> was originally published in <a href="https://medium.com/analytics-vidhya">Analytics Vidhya</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Write Effects for Actions in NgRx Data]]></title>
            <link>https://medium.com/better-programming/write-effects-for-actions-in-ngrx-data-214c93869758?source=rss-889d2fc474dc------2</link>
            <guid isPermaLink="false">https://medium.com/p/214c93869758</guid>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[ngrx]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[redux]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Karim]]></dc:creator>
            <pubDate>Wed, 29 Jul 2020 12:08:20 GMT</pubDate>
            <atom:updated>2020-08-31T19:26:51.408Z</atom:updated>
            <content:encoded><![CDATA[<h4>Intercepting @ngrx/data requests on the fly</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jiAVAcwZ_Lxzz8Po8uy56A.png" /></figure><p>Starting with a framework solves many problems; some of them are very hard to learn from the very beginning. However, we can even build many things faster than in a <a href="https://en.wikipedia.org/wiki/Vanilla_software">vanilla</a> mode. In fact, I almost used <a href="https://ngrx.io/guide/data">NgRx Data</a> before <a href="https://ngrx.io/">NgRx</a>.</p><p>Now, I am going to tell you about my experience with a problem — I couldn’t figure out a solution for a long time.</p><p>But before that, we will also learn how to:</p><ul><li>Create a dummy project in NgRx Data, and</li><li>customize the URL in NgRx data.</li></ul><p>To finally see how to intercept native NgRx data actions-request for firing effects.</p><h3>Introduction</h3><p>The Angular and NGRX teams have done magnificent work; however, you know that docs sometimes...</p><p>Anyways, the truth is that NgRx data makes the hard job of<a href="https://en.wikipedia.org/wiki/Create,_read,_update_and_delete">CRUD</a> communication that going through the back-end. We save a lot of time and effort, but at a price. It is normalization in <a href="https://medium.com/@stevenpcurtis.sc/rest-vs-crud-ca5522bf3fc3">REST</a> verbs for your request, and also in URLs routes coming to your back end. That’s it; quite simple, quite standard.</p><p>My question on <a href="https://stackoverflow.com/questions/61634055/how-do-i-write-effects-for-actions-in-ngrx-data">StackOverFlow</a>:</p><blockquote>“How do I write effects for “NATIVE” Actions in ngrx/data?</blockquote><blockquote>I know ngrx/data was created to get rid of Actions, Selectors, Effects, Reducers as much as it is possible, having therefore less boilerplate. However, there should be a way to create effects for NgRx Data.”</blockquote><p>Let’s me explain in another way. For my projects, I needed to listen to NgRx data actions, like, for example, <a href="https://ngrx.io/api/data/EntityOp#QUERY_ALL">QUERY_ALL: ‘@ngrx/data/query-all&#39;</a> or <a href="https://ngrx.io/api/data/EntityOp#QUERY_ALL_SUCCESS">QUERY_ALL_SUCCESS: ‘@ngrx/data/query-all/success’</a>, or others.</p><p>Does exist something like that?</p><pre><strong>fooNgrxDataEffectForQueryLoad</strong>$ = createEffect(() =&gt;<br>            this.actions$<br>                .pipe(<br>                    ofType((&#39;<strong>FooActionDispatchedByNgRxData</strong>&#39;)),</pre><p>Of course, the above <strong>code</strong> does <strong>not work,</strong> and nobody told me a way to catch these automatic requests (NgRx Data <strong><em>Actions</em></strong>) on the fly for writing <strong><em>Effects. </em></strong>I didn’t find anything by Googling or on StackOverFlow.</p><h3>A Dummy NgRx Data Project</h3><p>We need a project to apply our concepts with a practical example and materialize all the ideas in our minds.</p><p>Have a look at this website that offers us a simple fake rest API to play with. Yeah, we don’t need to build a back end!</p><p><a href="https://jsonplaceholder.typicode.com/">JSONPlaceholder</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*opcEYAsmcpY97wkqF6wh4w.png" /></figure><p>Our candidate for today is a list of posts, and that’s all about the API and back end.</p><h4>Defining the entities</h4><p>Now, let’s start the party with NgRx Data…</p><p>We are going to use <strong><em>posts</em></strong><em>, </em>so the very first thing we do is defining the entity…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*N-3MjIws1ScKuotMNlznPw.png" /></figure><p>interfaces.ts</p><pre>export default interface <strong>Post</strong> {<br>userId: number;<br>id: number;<br>title: string;<br>body: string;<br>}</pre><p>Then, we say to NgRx Data which entities to use:</p><p>entity.component.ts</p><pre>import { EntityMetadataMap } from &#39;@ngrx/data&#39;;</pre><pre>const entityMetadata: EntityMetadataMap = {<br>    <strong>Post</strong>: {}<br>};</pre><pre>export const <strong>entityConfig</strong> = {<br>    entityMetadata<br>};</pre><h4>Registering the entity store</h4><p>Just to load NgRx Data correctly:</p><p>app.module.ts</p><pre>...</pre><pre>@NgModule({<br>     imports: [<br>     HttpClientModule,<br>     StoreModule.forRoot({}),<br>     EffectsModule.forRoot([]),<br>     EntityDataModule.forRoot(<strong>entityConfig</strong>)<br>    ]<br>})</pre><pre>...</pre><h4>Creating entity data services</h4><p>Create a service that is doing all magical work of communication with the API:</p><p>post.service.ts</p><pre>import { Injectable } from &#39;@angular/core&#39;;<br>import {EntityCollectionServiceBase,EntityCollectionServiceElementsFactory} from &#39;@ngrx/data&#39;;<br>import Post from &#39;./interfaces&#39;;</pre><pre>@Injectable({ providedIn: &#39;root&#39; })<br>export class <strong>PostService</strong> extends <strong>EntityCollectionServiceBase</strong>&lt;<strong>Post</strong>&gt; {</pre><pre>constructor(serviceElementsFactory:  <strong>EntityCollectionServiceElementsFactory</strong>) {<br>  super(&#39;<strong>Post</strong>&#39;, serviceElementsFactory);<br>}</pre><h4>Using NgRx Data in components</h4><p>Now for <a href="https://medium.com/@michelestieven/components-stateful-stateless-dumb-and-smart-2847dd4092f2">Smart and Dumb</a> components. Here is our Smart component containing all the logic to retrieve data and so on with NgRx Data:</p><p>post-list.component.ts</p><pre>...</pre><pre>export class PostListComponent {</pre><pre>posts$: Observable&lt;Post[]&gt;;</pre><pre>constructor(private postService: PostService) {<br>   <strong>this.posts$ = postService.entities$;</strong><br>}</pre><pre>ngOnInit() {<br>   <strong>this.getPosts()</strong>;<br>}</pre><pre>getPosts() {<br>   <strong>this.postService.getAll()</strong>;<br>}<br><br>...</pre><p>post-list.component.html</p><pre>&lt;ng-container <strong>*ngFor</strong>=&quot;let post of <strong>posts$</strong> | <strong>async</strong>&quot;&gt;<br>     &lt;<strong>post</strong> <strong>[post]=&quot;post&quot;</strong>&gt;&lt;/<strong>post</strong>&gt;<br>&lt;/ng-container&gt;<br></pre><p>Our dumb:</p><p>post.component.ts</p><pre>export class <strong>PostComponent</strong>  {<br>  <strong>@Input()</strong> post: <strong>Post</strong>;</pre><p>post.component.html</p><pre>&lt;p class=&quot;title&quot;&gt;{{ <strong>post.id</strong> }}: {{ <strong>post.title</strong> }}&lt;/p&gt;<br>&lt;img [src]=&quot;&#39;https://picsum.photos/id/&#39;+<strong>post.userId</strong>+&#39;/200/200&#39;&quot; alt=&quot;Avatar&quot;&gt;<br>&lt;p class=&quot;body&quot;&gt;{{ <strong>post.body</strong> }}&lt;/p&gt;</pre><p>Note: we randomized photos through their IDs in our post with <a href="https://picsum.photos/">https://picsum.photos/</a> just to make it more real.</p><h3>A Custom URL</h3><p>Our jsonplaceholder back end API doesn’t fit <a href="https://ngrx.io/guide/data/entity-dataservice#configure-the-defaultdataservice">NgRx Data default config</a> in terms of their routes, then customization:</p><p>app.module.ts</p><pre>const defaultDataServiceConfig: DefaultDataServiceConfig = {<br>    root: &#39;https://jsonplaceholder.typicode.com/&#39;<br>}</pre><pre>...</pre><pre>@NgModule({</pre><pre>imports: [</pre><pre>...</pre><pre>providers: [{ provide: DefaultDataServiceConfig, <br>useValue: defaultDataServiceConfig }]</pre><pre>...</pre><p>Some other minor tasks were done to prettify our list of posts and make it work perfectly.</p><h3>Intercepting Actions</h3><h4>How does it look like in NgRx Data?</h4><p>Remember what we do in post-list.component.ts?</p><pre><strong>this.posts$ = postService.entities$;</strong><br>...</pre><pre><strong>this.postService.getAll()</strong>;</pre><p>These lines of code activate all the magic behind them with a couple of actions:</p><ul><li><a href="https://ngrx.io/api/data/EntityOp#QUERY_ALL">QUERY_ALL: ‘@ngrx/data/query-all’</a></li><li><a href="https://ngrx.io/api/data/EntityOp#QUERY_ALL_SUCCESS">QUERY_ALL_SUCCESS: ‘@ngrx/data/query-all/success</a></li></ul><p>First action <strong>[Post] ngrx/data/query-all:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bXtPIwbi_K4kjunNiNYyyw.png" /></figure><p>Send a request:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/972/1*RXlqkDJV-n6vwe2kqkgJYA.png" /></figure><p>To retrieve all the data with:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dim_xC3vSC1aL2Su14pz2g.png" /></figure><p>Their response:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VtX-OaJYoFaN4fH0N4uG0w.png" /></figure><p>And the result in the UI:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*-h-n-pPifCuhHuIvj8qlEA.png" /></figure><h4>WoW NgRx Effect</h4><p>Finally, the reason why we created this project:</p><p>post.effects.ts</p><pre>...</pre><pre>@Injectable()<br>export class <strong>PostEffects</strong> {</pre><pre><strong>ngrxDataEffectForQueryLoad$</strong> = createEffect( </pre><pre>() =&gt;this.actions$.pipe(</pre><pre><strong>ofEntityType(&quot;Post&quot;),<br>ofEntityOp([EntityOp.QUERY_ALL_SUCCESS]),</strong></pre><pre>tap(action =&gt;</pre><pre>console.log(&quot;%c%s&quot;,&quot;color: green; background: yellow; font-size: 24px;&quot;,&quot;Your 🎸🎸🎸 WOW 😲😲😲 Effect here 🚀🚀🚀!&quot;))),</pre><pre>{ dispatch: false }</pre><pre>);</pre><pre>...</pre><p>Don’t forget to register them in the app:</p><p>app.module.ts</p><pre>...</pre><pre>@NgModule({<br>imports: [</pre><pre>...</pre><pre><strong>EffectsModule.forRoot([PostEffects])</strong>,<br>],</pre><pre>...</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YChJVVj0CNGIawRlfWClBg.png" /><figcaption>Now, we see it in the console.</figcaption></figure><p>Not very difficult, beyond filtering Post entities and also the QUERY_ALL_SUCCESS operation — no need to explain much. Remember you can do this for all <a href="https://ngrx.io/api/data/EntityOp">https://ngrx.io/api/data/EntityOp</a> operations as well.</p><p>This is a good trick that you may hardly find if you don’t read this or see it anywhere else.</p><p>As you see I have left the WoW Effect part for you, I didn’t want to make the article longer… now, you are able to fire effects from NgRx data actions!</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fstackblitz.com%2Fedit%2Fangular-ivy-ngrx-data-effects4actions%3Fembed%3D1%26file%3Dsrc%252Fapp%252Fapp.module.ts&amp;display_name=StackBlitz&amp;url=https%3A%2F%2Fstackblitz.com%2Fedit%2Fangular-ivy-ngrx-data-effects4actions%3Ffile%3Dsrc%252Fapp%252Fapp.module.ts&amp;image=https%3A%2F%2Fc.staticblitz.com%2Fassets%2Ficon-03bbb9acbba813917725387f46e5df03a95d232be240e910ce5f946a973b3f86.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=stackblitz" width="745" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/043e0b3dd362fcc7bbcb341db0c5df09/href">https://medium.com/media/043e0b3dd362fcc7bbcb341db0c5df09/href</a></iframe><p>⤣ <em>Repo at this point (</em><a href="https://stackblitz.com/edit/angular-ivy-ngrx-data-effects4actions"><em>StackBlitz</em></a><em> OR </em><a href="https://github.com/ackuser/angular-ivy-ngrx-data-effects4actions/tree/develop"><em>GitHub</em></a><em> on branch develop)</em>⤤</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/220/0*qBk35Y0jVWCDtGzv.png" /></figure><h3>Conclusion</h3><p>I love NgRx Data. If you are a newbie on the subject, now you know how to quickly implement a project with NgRx data.</p><p>On the other hand, if you already know NgRx data but you have never seen how to fire <em>Effects/Magic</em> from NgRx Data <em>Actions/Requests,</em> or you’re stuck with this, I hope this article was helpful for you.</p><p>I always like to recommend helpful articles from others:</p><ul><li><a href="https://medium.com/@felipenoratolacerda/super-fast-stateful-crud-a-practical-guide-to-ngrx-data-9aaf89186348">Super Fast Stateful CRUD — A practical guide to NgRx Data</a></li><li><a href="https://medium.com/better-programming/ngrx-data-will-change-your-life-8528736e4fc0">@ngrx/data Will Change Your Life</a></li></ul><h3>Next Steps</h3><p>We want to 🎸 NgRx, so stay tuned to see other features &amp; customizations!</p><p>Thanks for reading.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=214c93869758" width="1" height="1" alt=""><hr><p><a href="https://medium.com/better-programming/write-effects-for-actions-in-ngrx-data-214c93869758">How to Write Effects for Actions in NgRx Data</a> was originally published in <a href="https://betterprogramming.pub/">Better Programming</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Intro to @ngrx/component]]></title>
            <link>https://medium.com/better-programming/intro-to-ngrx-component-15c0dfd9b44a?source=rss-889d2fc474dc------2</link>
            <guid isPermaLink="false">https://medium.com/p/15c0dfd9b44a</guid>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[ngrx]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[typescript]]></category>
            <dc:creator><![CDATA[Karim]]></dc:creator>
            <pubDate>Wed, 22 Jul 2020 16:43:56 GMT</pubDate>
            <atom:updated>2020-07-30T21:28:35.446Z</atom:updated>
            <content:encoded><![CDATA[<h4>A comprehensive guide to improving your NGRX projects (part 2)</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yIEH3_qC-Pgnv8t8Y56wIA.png" /><figcaption>Image provided by the author.</figcaption></figure><p>New features are coming into NGRX, one of which is <a href="https://ngrx.io/guide/component">ngrx/component</a>. It brings plenty of opportunities to make our programming easier &amp; faster. Apparently, it appears onto the scene to help us get rid of the <a href="https://angular.io/api/common/AsyncPipe">async</a> pipe in templates. But also, under the hood, it takes maximum advantage for Angular life cycles.</p><p>We will explore it briefly, and in the meantime, you will see the base of some concepts to understand why we should use this. Finally, we are going to apply it to an easy project done with NGRX, getting the benefits of this feature.</p><h3>The Use Case</h3><p>The use case is a simple to-do list built with Angular and NGRX superpower that we’ve already seen and improved in Part 1.</p><p><a href="https://medium.com/better-programming/refactoring-reducers-states-for-a-better-store-cdb355632fbf">Refactoring Reducers and States for a Better Store</a></p><h3>Introduction</h3><p>What is @ngrx/components?</p><p>From Docs:</p><blockquote>Component is a set of primitive reactive helpers to enable fully reactive, fully zone-less applications. They give more control over rendering, and provide further reactivity for Angular applications.</blockquote><p>In plain English:</p><blockquote>Directives &amp; Pipes to eliminate the use of Zones and improve the handling of Observables in Angular templates.</blockquote><p>At the present moment, there are two:</p><ul><li>*<a href="https://ngrx.io/guide/component/let">ngrxLet</a></li><li><a href="https://ngrx.io/guide/component/push">ngrxPush</a></li></ul><p>But before we dive into them, let’s clarify why the need to replace the async pipe:</p><blockquote>The problem is async pipe just marks the component and all its ancestors as dirty. It needs zone.js microtask queue to exhaust until <a href="https://angular.io/api/core/ApplicationRef">ApplicationRef.tick</a> is called to render all dirty marked components.</blockquote><blockquote>Heavy dynamic and interactive UIs suffer from zones change detection a lot and can lean to bad performance or even unusable applications, but the async pipe does not work in zone-less mode.</blockquote><h3>Key Concepts</h3><h4>1. NgZone</h4><p>Summarising, thanks to<a href="https://angular.io/guide/zone">NgZone</a> Angular makes for us the detection of changes automatically in components with the aim of updating our HTMLs. Obviously, it costs in terms of CPU processing.</p><p>Problems with detect changes coming up with User Events, Requests &amp; Timers that have something in common with Asynchronicity. Despite this, any time we use Observable, the right time is known to make the detection of changes and be rendered in our UI. And that changes everything.</p><p>Let’s see some examples so we can clarify all of these concepts about updating HTMLs.</p><p><strong>Plain/vanilla javascript:</strong></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fstackblitz.com%2Fedit%2Fjs-detect-changes%3Fembed%3D1%26file%3Dindex.js&amp;display_name=StackBlitz&amp;url=https%3A%2F%2Fstackblitz.com%2Fedit%2Fjs-detect-changes%3Ffile%3Dindex.js&amp;image=https%3A%2F%2Fc.staticblitz.com%2Fassets%2Ficon-1d2450aadcf984376236c23cd2ab0ba231ddd1d85c9b72990ed2ede5b4974d1b.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=stackblitz" width="745" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/217d4114b5b91a06b6dfb14a56320330/href">https://medium.com/media/217d4114b5b91a06b6dfb14a56320330/href</a></iframe><p><strong>Angular, default configuration:</strong></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fstackblitz.com%2Fedit%2Fangular-ivy-detect-changes%3Fembed%3D1%26file%3Dsrc%252Fapp%252Fclick-me%252Fclick-me.component.ts&amp;display_name=StackBlitz&amp;url=https%3A%2F%2Fstackblitz.com%2Fedit%2Fangular-ivy-detect-changes%3Ffile%3Dsrc%252Fapp%252Fclick-me%252Fclick-me.component.ts&amp;image=https%3A%2F%2Fc.staticblitz.com%2Fassets%2Ficon-1d2450aadcf984376236c23cd2ab0ba231ddd1d85c9b72990ed2ede5b4974d1b.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=stackblitz" width="745" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/fddd5900256728aa569eb64146fef30f/href">https://medium.com/media/fddd5900256728aa569eb64146fef30f/href</a></iframe><p><strong>Angular, without NgZone:</strong></p><p>Disabling Zone in Angular</p><ol><li>Comment zone.js line in polyfills.ts:</li></ol><pre>//&#39;zone.js/dist/zone&#39;;</pre><p>2. Bootstrap Angular with the noop zone in src/main.ts:</p><pre>platformBrowserDynamic().bootstrapModule(AppModule,{ ngZone:&#39;noop&#39;})</pre><p>Now NgZone is not used anymore so detection is not automatic.</p><p>3. However, we can trigger it manually and it will work fine, src/click-me/click-me.component.ts:</p><pre> ...</pre><pre>constructor(private changeDetector: ChangeDetectorRef) {}</pre><pre> ...</pre><pre>onClickMe() {<br>  this.clickMessage = ‘You are the best!’;<br>  this.changeDetector.detectChanges();<br>}</pre><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fstackblitz.com%2Fedit%2Fangular-ivy-detect-changes-zoneless%3Fembed%3D1%26file%3Dsrc%252Fapp%252Fclick-me%252Fclick-me.component.ts&amp;display_name=StackBlitz&amp;url=https%3A%2F%2Fstackblitz.com%2Fedit%2Fangular-ivy-detect-changes-zoneless%3Ffile%3Dsrc%252Fapp%252Fclick-me%252Fclick-me.component.ts&amp;image=https%3A%2F%2Fc.staticblitz.com%2Fassets%2Ficon-1d2450aadcf984376236c23cd2ab0ba231ddd1d85c9b72990ed2ede5b4974d1b.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=stackblitz" width="745" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/32057f118dcb17f65528c2c9cc92d722/href">https://medium.com/media/32057f118dcb17f65528c2c9cc92d722/href</a></iframe><p>Less computing in the backend is the main advantage. On the other hand, deactivating part of the core makes us responsible for change detection for Angular (and that is not easy at all).</p><p>If you want to go deeper, here are a couple of really good readings.</p><ul><li><a href="https://medium.com/better-programming/zone-js-for-angular-devs-573d89bbb890">10 Things Every Angular Developer Should Know About Zone.js</a></li><li><a href="https://indepth.dev/do-you-still-think-that-ngzone-zone-js-is-required-for-change-detection-in-angular/">Do you still think that NgZone (zone.js) is required for change detection in Angular?</a></li></ul><h4>2. Null and undefined is the same but not exactly the same</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/310/1*Mpb3pmAgxoGHcVXFtFSEHw.png" /><figcaption>It is important to have this clear, right?</figcaption></figure><h4>3. Operator DistinctUntilChanged in RxJS</h4><p>The distinctUntilChanged() operator ignores duplicate consecutive emissions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/820/1*oHKRWi7xeTY7A6NVxN2b6Q.png" /><figcaption>Have a quick look to what its Marble representation looks like. Docs here, <a href="https://rxjs-dev.firebaseapp.com/api/operators/distinctUntilChanged">https://rxjs-dev.firebaseapp.com/api/operators/distinctUntilChanged</a></figcaption></figure><h3>Using ngrxLet</h3><p><a href="https://ngrx.io/guide/component/let">This</a> directive serves a convenient way of binding observables to a view context (a dom element scope).</p><h4>Use in our project</h4><p>todo-list.component.ts</p><pre>&lt;ng-container *ngrxLet=”todos$ as todos”&gt;</pre><pre>&lt;todo *ngFor=”let todo of todos” [todo]=”todo” (onRemoveTodo)=”removeTodo($event)”<br>(onToggleTodo)=”toggleTodo($event)”&gt;<br>&lt;/todo&gt;</pre><pre>&lt;/ng-container&gt;</pre><p><a href="https://ngrx.io/guide/component/let#included-features">Technical features</a>:</p><ul><li>Takes away the multiple usages of the async or ngrxPush pipe.</li></ul><p>Verified.</p><ul><li>Unifies the way of handling null and undefined.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/582/1*JSs2qK5ryYnZHQ6rEdkAyA.png" /><figcaption><a href="https://github.com/ngrx/platform/blob/5353343d5996dbff5ba5359071d8f7afc8ab4b7c/modules/component/src/core/cd-aware/cd-aware_creator.ts#L48">Source</a></figcaption></figure><ul><li>Distinct same values in a row (distinctUntilChanged operator)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/826/1*RgLRKvUkYgTAu89zZ07n7Q.png" /><figcaption><a href="https://github.com/ngrx/platform/blob/5353343d5996dbff5ba5359071d8f7afc8ab4b7c/modules/component/src/core/cd-aware/cd-aware_creator.ts#L63">Source</a></figcaption></figure><ul><li>Triggers change-detection differently if zone.js is present or not (detectChanges or markForCheck).</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/537/1*eRkfolVnTsMF-QmI8DD3lw.png" /><figcaption><a href="https://github.com/ngrx/platform/blob/5353343d5996dbff5ba5359071d8f7afc8ab4b7c/modules/component/src/core/cd-aware/creator_render.ts#L9">Source</a></figcaption></figure><h3>Using ngrxPush</h3><p><a href="https://ngrx.io/guide/component/push">This</a> pipe serves as a drop-in replacement for the async pipe. It contains intelligent handling of change detection to enable us to run in zone-full as well as zone-less mode without any changes to the code.</p><h4><strong>Use in our project</strong></h4><p>todo-list.component.html</p><pre>&lt;todo *ngFor=”let todo of todos$ | ngrxPush” [todo]=”todo” (onRemoveTodo)=”removeTodo($event)” (onToggleTodo)=”toggleTodo($event)”&gt;<br>&lt;/todo&gt;</pre><p><a href="https://ngrx.io/guide/component/let#included-features">Technical features</a>:</p><ul><li>Observables &amp; promises retrieve their values &amp; render them to the template.</li></ul><p>All correct here.</p><p>Note: This pipe only works when we use the <a href="https://ngrx.io/guide/store">Store</a>. Just in case you want to use it for whatever reason without using NGRX, it won’t work.</p><p>Let me explain it to you with code.</p><p>todo-list.component.ts</p><pre>ngOnInit() {</pre><pre>// this.todos$ = this.store.select(selectTodos);</pre><pre>this.todos$ = <strong>of</strong>([{ id: “123”, text: “new task”, todo: true }]);</pre><p>It is still an Observable list, but if you don’t do it through a selector, then it simply won’t process the to-do list in your template.</p><ul><li>Distinct same values in a row to increase performance, unify null and undefined values and triggers change-detection differently if zone.js is present or not (detectChanges or markForCheck).</li></ul><p>Same as ngrxLet, they even share that part of the code.</p><ul><li>Coalescing of change detection calls to boost performance</li></ul><p>For the sake of simplicity in this article, you must think of it as a way to aggregate change detection to make it faster.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*r_DQ5HhwP8PYpfq-SrcVEA.png" /><figcaption>Image provided by the author.</figcaption></figure><h3>And Now, Both <strong>*ngrxLet</strong> &amp; <strong>ngrxPush</strong></h3><p>src/main.ts:</p><pre>platformBrowserDynamic().bootstrapModule(AppModule,{ ngZone:&#39;noop&#39;})</pre><p>It works without zone!</p><p>Note: At the time I wrote this article, the package was an experimental package and was in development, so it may have some changes. You may have to deactivate <a href="https://angular.io/guide/aot-compiler">AOT</a> compilation and it will work with Angular version 8.x. Also, Angular/components behavior is a little bit different depending on the View Engine or Ivy.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fstackblitz.com%2Fedit%2Fngrx-custom-reducers-todo-list%3Fembed%3D1%26file%3Dsrc%252Fapp%252Ftodos%252Ftodo-list%252Ftodo-list.component.html&amp;display_name=StackBlitz&amp;url=https%3A%2F%2Fstackblitz.com%2Fedit%2Fngrx-custom-reducers-todo-list%3Ffile%3Dsrc%252Fapp%252Ftodos%252Ftodo-list%252Ftodo-list.component.html&amp;image=https%3A%2F%2Fc.staticblitz.com%2Fassets%2Ficon-03bbb9acbba813917725387f46e5df03a95d232be240e910ce5f946a973b3f86.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=stackblitz" width="745" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/31e15803eb0458ad0e11cefa2b7f6cf0/href">https://medium.com/media/31e15803eb0458ad0e11cefa2b7f6cf0/href</a></iframe><p><em>Repo at this point (</em><a href="https://stackblitz.com/edit/ngrx-custom-reducers-todo-list"><em>StackBlitz</em></a><em> on branch feature/ngrx_components_stackblitz or </em><a href="https://github.com/ackuser/ngrx-custom-reducers-todo-list/tree/feature/ngrx_components"><em>GitHub</em></a><em> on branch feature/ngrx_components)</em></p><h3>Conclusion</h3><p>I hope you now know the basics and some key concepts to understand “<em>@ngrx/component.</em>” Also, its importance and why we remove the use of the async pipe which drastically reduces operations done behind the scene.</p><p>In addition, the separation of concerns independently if Angular works with or without zone is great for performance and improving the time of execution. It would be really nice to profile &amp; measure how much better when we are in zoneless mode. Try to align your project with the future of where NGRX goes!</p><p>We will cover other interesting topics of NGRX soon so stay tuned!!!</p><p>I encourage you to have a look at some further readings:</p><ul><li><a href="https://medium.com/ngconf/a-first-look-at-ngrx-component-f7fcbf83669a">A First Look at @ngrx/component</a></li><li><a href="https://christiankohler.net/reactive-angular-with-ngrx-component">Reactive Angular with ngrx/component</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=15c0dfd9b44a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/better-programming/intro-to-ngrx-component-15c0dfd9b44a">Intro to @ngrx/component</a> was originally published in <a href="https://betterprogramming.pub/">Better Programming</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>