<?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"><channel><title><![CDATA[Devzilla]]></title><description><![CDATA[Devzilla]]></description><link>https://devzilla.io</link><image><url>https://cdn.hashnode.com/res/hashnode/image/upload/v1725627092686/eea64e92-dfd5-4a8c-993a-a12936ec908e.png</url><title>Devzilla</title><link>https://devzilla.io</link></image><generator>RSS for Node</generator><lastBuildDate>Wed, 15 Apr 2026 06:09:51 GMT</lastBuildDate><atom:link href="https://devzilla.io/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><atom:link rel="first" href="https://devzilla.io/rss.xml"/><item><title><![CDATA[Using NodeJs 14 with Mac Silicon (M1)]]></title><description><![CDATA[<p>I have recently received a new MacBook Pro with the Mac Silicon chip. However, I noticed that I am unable to compile NodeJs Version 14 which I have to use due to some of my projects are still on Angular 11 and 12.</p>
<p>Unfortunately, there is no NodeJs 14 that is built for ARM64; Hence it has no support for the new Mac Silicon which is built around ARM64.</p>
<p>Fortunately, there is some workaround to get NodeJs 14 to work with Mac Silicon. Apple provides Rosetta, a translation app that allows applications that are built for Intel Chip (or previous generation Mac) to run under Apple Silicon.</p>
<h3 id="heading-installing-rosetta"><strong>Installing Rosetta</strong></h3>
<p>To install Rosetta, you need to:</p>
<ol>
<li><p>Open your terminal</p>
</li>
<li><p>Paste and execute <code>/usr/sbin/softwareupdate --install-rosetta --agree-to-license</code></p>
</li>
</ol>
<p>And that's it!</p>
<h3 id="heading-installing-nodejs-14"><strong>Installing NodeJs 14</strong></h3>
<p>For any Node installation in Mac, I recommend you to use <a target="_blank" href="https://github.com/nvm-sh/nvm">NVM</a>. It allows you to easily swap between Node versions through CLI.</p>
<p>To install NVM:</p>
<ol>
<li><p>Open your terminal</p>
</li>
<li><p>Paste and execute <code>curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash</code></p>
</li>
<li><p>Restart your terminal</p>
</li>
</ol>
<p>You can confirm that NVM has been successfully installed by executing <code>nvm</code> command in your terminal.</p>
<p>Now, to get to the real deal on installing NodeJs 14, we will execute everything through terminal.</p>
<ol>
<li><p>Open your terminal</p>
</li>
<li><p>Execute <code>arch</code> and confirm that at the moment it is returning <code>arm64</code></p>
</li>
<li><p>Execute <code>arch -x86_64 zsh</code></p>
</li>
<li><p>Execute <code>arch</code> and confirm that it is now returning <code>i386</code></p>
</li>
<li><p>Execute <code>nvm install 14</code>. NVM will install the latest NodeJs 14.</p>
</li>
<li><p>Execute <code>nvm use 14</code> to switch to NodeJs 14, if you have other NodeJs versions installed.</p>
</li>
</ol>
<p>That's it, folks! You now are able to use NodeJs 14 with your new Mac.</p>
]]></description><link>https://devzilla.io/using-nodejs-14-with-mac-silicon-m1</link><guid isPermaLink="true">https://devzilla.io/using-nodejs-14-with-mac-silicon-m1</guid><category><![CDATA[Node.js]]></category><category><![CDATA[macbook]]></category><category><![CDATA[M1 Mac]]></category><category><![CDATA[m1-macbook]]></category><dc:creator><![CDATA[Gabriel George]]></dc:creator></item><item><title><![CDATA[Manage RxJS Subscriptions in Angular]]></title><description><![CDATA[<p><a target="_blank" href="https://angular.io/guide/rx-library">RxJS</a> is baked into Angular's environment and is heavily used behind the scenes inside Angular. You will notice that when you create your brand new Angular app with <code>ng new newApp</code> or using Visual Studios Angular template, <code>RxJS</code> is always included as one of the core dependencies.</p>
<p>But first, what is RxJS?</p>
<blockquote>
<p><em>RxJS is a library for composing asynchronous and event-based programs by using observable sequences -</em> <a target="_blank" href="https://rxjs.dev/guide/overview"><em>RxJS</em></a></p>
</blockquote>
<p>Since RxJS is baked into Angular we are so used to the fact we need to <code>subscribe</code> for us to receive data from our various services, e.g. HttpClient, NgRx Store or event.</p>
<h2 id="heading-what-is-a-subscription"><strong>What is a Subscription?</strong></h2>
<p>To understand what a Subscription is, we need to first understand several terminologies in RxJS.</p>
<h3 id="heading-observable"><strong>Observable</strong></h3>
<p>According to RxJS docs, <a target="_blank" href="https://rxjs-dev.firebaseapp.com/api/index/class/Observable">Observable</a> is a representation of any set of values over any amount of time.<br /><code>Observable</code> has <code>subscribe()</code> method, which invokes the execution of an <code>Observable</code> and registers <a target="_blank" href="https://rxjs-dev.firebaseapp.com/guide/observer">Observer</a> handlers for notifications it will emit.</p>
<h3 id="heading-subscription"><strong>Subscription</strong></h3>
<p>Now that we understand <code>Observable</code> and <code>subscribe()</code> method, now we are ready to talk about <a target="_blank" href="https://rxjs-dev.firebaseapp.com/guide/subscription">Subscription</a>. In a nutshell, a Subscription:</p>
<ul>
<li><p>Is a disposable resource, usually the execution of an <code>Observable</code> (allowing value to be streamed out of observable)</p>
</li>
<li><p>There is one important method, <code>unsubscribe()</code>, which disposes of the resource held by the Subscription</p>
</li>
</ul>
<h2 id="heading-sample-use-case"><strong>Sample use case</strong></h2>
<p>You have a Web API available that provides endpoints for adding, editing, and retrieving Todo Items. Now you want to display these Todo items in an application.</p>
<p>To get all the data, we have to:</p>
<ol>
<li><p>Send an HTTP request</p>
</li>
<li><p>Subscribe to the Observable using <code>subscribe()</code> with a fat arrow function that will eventually receive the todo item payload</p>
</li>
<li><p>Inside our fat arrow function, we can assign the incoming todo item to a local variable (which will/can trigger a UI update)</p>
</li>
</ol>
<pre><code class="lang-TS"><span class="hljs-built_in">this</span>.httpClient
    .get(<span class="hljs-string">'https://jsonplaceholder.typicode.com/todos'</span>)
    .subscribe(<span class="hljs-function">(<span class="hljs-params">todos</span>) =&gt;</span> {
      ...
    });
</code></pre>
<p>It would be nice always to have the latest data. We can continually fetch the new data by polling the endpoint every 10 seconds.</p>
<pre><code class="lang-ts">interval(<span class="hljs-number">10000</span>).subscribe(<span class="hljs-function">() =&gt;</span> {
      <span class="hljs-built_in">this</span>.httpClient
        .get(<span class="hljs-string">'https://jsonplaceholder.typicode.com/todos'</span>)
        .subscribe(<span class="hljs-function">(<span class="hljs-params">todos</span>) =&gt;</span> {
          ...
        });
      });
</code></pre>
<p>However, little did we know that our code above was doing more than we intended. We somehow ended up bombarding the server with request after a few navigations back and forth. It went from fetching once every 10 seconds to once every a few seconds, and sometimes double fetching occurred.</p>
<p>Up to this point, we now realised that even if the component gets destroyed, the subscription will remain until we told them otherwise.</p>
<h2 id="heading-solutions"><strong>Solutions</strong></h2>
<h3 id="heading-1-unsubscribe-all-subscriptions"><strong>1. Unsubscribe all Subscriptions</strong></h3>
<p>I think this sounds like the most sensible way when we think about the subscription.<br />Of course, all subscription needs to be unsubscribed for it to be stopped.</p>
<h4 id="heading-unsubscribe-single-subscription"><strong>Unsubscribe single subscription</strong></h4>
<pre><code class="lang-ts">ngOnInit() {
  <span class="hljs-comment">// Assign the subscription to a variable</span>
  <span class="hljs-built_in">this</span>.subscription = interval(<span class="hljs-number">10000</span>).subscribe(<span class="hljs-function">() =&gt;</span> {
    ...
  });
}

ngOnDestroy() {
  <span class="hljs-comment">// Manually unsubscribe subscription on ngDestroy life-cycle</span>
  <span class="hljs-built_in">this</span>.subscription.unsubscribe();
}
</code></pre>
<h4 id="heading-unsubscribe-multiple-subscriptions-in-an-array"><strong>Unsubscribe multiple subscriptions in an array</strong></h4>
<pre><code class="lang-ts">ngOnInit() {
  <span class="hljs-comment">// Push every subscriptions to an array of subscriptions</span>
  <span class="hljs-built_in">this</span>.subscriptions.push(
    interval(<span class="hljs-number">10000</span>).subscribe(<span class="hljs-function">() =&gt;</span> {
      ...
    })
  );
}

ngOnDestroy() {
  <span class="hljs-comment">// Loop on every subscriptions and unsubscribe</span>
  <span class="hljs-built_in">this</span>.subscriptions.forEach(<span class="hljs-function">(<span class="hljs-params">subscription</span>) =&gt;</span> {
    subscription.unsubscribe();
  });
}
</code></pre>
<h3 id="heading-2-completing-subscription-using-rxjs-pipe"><strong>2. Completing Subscription using RxJS pipe</strong></h3>
<p>Before we head into RxJS pipe, let us first understand what a <code>pipe</code> is. It is not the same as a pipe with the symbol of <code>|</code>. Pipe in RxJS is a chain of Pipeable Operators, which is a pure function that takes an Observable as an input and emits a new Observable as the output (<a target="_blank" href="https://rxjs-dev.firebaseapp.com/guide/operators">read more</a>).</p>
<p>There are various ways to complete RxJS through pipe. I'll share my top three operators.</p>
<h4 id="heading-take"><strong>take()</strong></h4>
<p><code>take</code> operator lives up to its name. It will only take a number passed through the function and then unsubscribe itself.</p>
<pre><code class="lang-ts">ngOnInit() {
  interval(<span class="hljs-number">10000</span>)
    <span class="hljs-comment">// Take 10 values then unsubscribe the stream</span>
    .pipe(take(<span class="hljs-number">10</span>))
    .subscribe(<span class="hljs-function">(<span class="hljs-params">x</span>) =&gt;</span> {
      ...
    });
}
</code></pre>
<h4 id="heading-takewhile"><strong>takeWhile()</strong></h4>
<p><code>takeWhile</code> operator will unsubscribe the Observable stream when the function call inside <code>takeWhile</code> returns false.</p>
<pre><code class="lang-ts"><span class="hljs-keyword">private</span> _componentExist = <span class="hljs-literal">true</span>;

ngOnInit() {
  interval(<span class="hljs-number">10000</span>)
    <span class="hljs-comment">// takeWhile pipe will accept stream as long as the value returns true.</span>
    <span class="hljs-comment">// When the value is false, it will terminate the stream</span>
    .pipe(takeWhile(<span class="hljs-function">() =&gt;</span> <span class="hljs-built_in">this</span>._componentExist))
    .subscribe(<span class="hljs-function">() =&gt;</span> {
      ...
    });
}

ngOnDestroy() {
  <span class="hljs-built_in">this</span>._componentExist = <span class="hljs-literal">false</span>;
}
</code></pre>
<p>Do notice that if the <code>Observable</code> stream does not emit any new value, the subscription will never be terminated, since the <code>takeWhile</code> operator requires a stream to pass through to terminate itself.</p>
<h4 id="heading-takeuntil"><strong>takeUntil()</strong></h4>
<p><code>takeUntil</code> will accept any streamed values until the <code>Observable</code> function in the <code>takeUntil</code> emits a value. You might want to use this approach when the two approaches above do not suit your use case.</p>
<pre><code class="lang-ts"><span class="hljs-keyword">private</span> ngDestroy$ = <span class="hljs-keyword">new</span> Subject();

ngOnInit() {
  interval(<span class="hljs-number">10000</span>)
    .pipe(takeUntil(<span class="hljs-built_in">this</span>.ngDestroy$))
    .subscribe(<span class="hljs-function">(<span class="hljs-params">x</span>) =&gt;</span> {
      ...
    });
}

ngOnDestroy() {
  <span class="hljs-comment">// Emit value to make all takeUntil gets triggered</span>
  <span class="hljs-built_in">this</span>.ngDestroy$.next();
  <span class="hljs-comment">// Then complete its own subscription to make sure there is no loose end</span>
  <span class="hljs-built_in">this</span>.ngDestroy$.complete();
}
</code></pre>
<h3 id="heading-3-use-angular-async-pipe"><strong>3. Use Angular async pipe</strong></h3>
<p>Angular comes with an amazing <code>async</code> pipe, which allows an <code>observable</code> value to be streamed directly into the html template. The benefit of this approach is that you dont have to manage anything. Angular will manage it for you, and it will follow the component's life cycle.</p>
<p>TS:</p>
<pre><code class="lang-ts">todos$: Observable&lt;Todo[]&gt;;

ngOnInit() {
  <span class="hljs-built_in">this</span>.todos$ = interval(<span class="hljs-number">10000</span>).pipe(
    ...
  );
}
</code></pre>
<p>HTML:</p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">ul</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">li</span> *<span class="hljs-attr">ngFor</span>=<span class="hljs-string">"let todo of (todos$ | async)"</span>&gt;</span>
    {{ todo | json }}
  <span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span> 
<span class="hljs-tag">&lt;/<span class="hljs-name">ul</span>&gt;</span>
</code></pre>
<h2 id="heading-summary"><strong>Summary</strong></h2>
<p>Make sure you terminate all RxJS subscriptions. You have seen that in a small-scale application, an unterminated subscription can cause some unwanted effects. Imagine what could happen in an enterprise app where there are so many subscriptions happening.</p>
<p>We've learnt that in Angular, you can terminate a subscription either by:</p>
<ol>
<li><p>Unsubscribe all subscriptions manually</p>
</li>
<li><p>Completing Subscription using RxJS pipe:<br /> a. <code>take</code> operator<br /> b. <code>takeWhile</code> operator<br /> c. <code>takeUntil</code> operator</p>
</li>
<li><p>Use Angular <code>async</code> pipe and let Angular do it for you</p>
</li>
</ol>
<p>Each of them has their strong points. You need to know when to use it according to your own needs.</p>
<p>Personally, I would recommend using <code>async</code> when the data stream is only being used in the HTML template and use <code>takeUntil</code> if the data is being used in the component. You definitely can mix the usage according to your circumstances.</p>
<p>Now we can all have a fun time with subscriptions!</p>
]]></description><link>https://devzilla.io/manage-rxjs-subscriptions-in-angular</link><guid isPermaLink="true">https://devzilla.io/manage-rxjs-subscriptions-in-angular</guid><category><![CDATA[Angular]]></category><category><![CDATA[RxJS]]></category><dc:creator><![CDATA[Gabriel George]]></dc:creator></item><item><title><![CDATA[CSS guide for dev dummies]]></title><description><![CDATA[<p>Sometimes writing CSS can be a tedious task even for those who are experienced. It's even worse for those who are new to web development. For the past few years doing web development for various clients, I have noticed that the usual pitfalls of writing CSS fell into one of these:</p>
<ol>
<li><p>CSS was written in such a specific way (sometimes too specific).</p>
</li>
<li><p>Inconsistencies in how devs write CSS classes. The default standard for most CSS should be written in kebab-case. But I have seen a mixture of kebab-case, camelCase, and also TitledCase in a single project.</p>
</li>
<li><p>Blindly implementing the whole Bootstrap framework as well as trying to keep own branding. I have seen teams import <code>bootstrap.min.css</code> then try hard to override those stylings that they don't like.</p>
</li>
</ol>
<p>So, here are a few tips that can reduce the pain of writing CSS:</p>
<h3 id="heading-1-be-consistent"><strong>1. Be consistent</strong></h3>
<p>Most front-end developers type CSS in all lower-case with <code>-</code> (hyphen) as the separator between words (e.g.: <code>.table-heading</code>). But, if your team has already done a camel case or titled case, make sure everything stays consistent.</p>
<h3 id="heading-2-make-reusable-classes"><strong>2. Make reusable classes</strong></h3>
<p>The idea of writing CSS is to make them as reusable as possible to reduce the need for repeating the same code.<br />Avoid writing CSS like:</p>
<pre><code class="lang-css"><span class="hljs-selector-tag">div</span><span class="hljs-selector-id">#card</span> {
    <span class="hljs-attribute">background-color</span>: <span class="hljs-number">#eee</span>;
    <span class="hljs-attribute">color</span>: <span class="hljs-number">#000</span>;
    <span class="hljs-attribute">text-align</span>: center;
}
</code></pre>
<p>Write it in a more reusable way:</p>
<pre><code class="lang-css"><span class="hljs-selector-class">.card</span> {
    <span class="hljs-attribute">background-color</span>: <span class="hljs-number">#eee</span>;
    <span class="hljs-attribute">color</span>: <span class="hljs-number">#000</span>;
    <span class="hljs-attribute">text-align</span>: center;
}
</code></pre>
<p>You can further normalise the CSS for further reusability:</p>
<pre><code class="lang-css"><span class="hljs-selector-class">.bg-grey</span> {
    <span class="hljs-attribute">background-color</span>: <span class="hljs-number">#eee</span>;
}

<span class="hljs-selector-class">.color-black</span> {
    <span class="hljs-attribute">color</span>: <span class="hljs-number">#000</span>;
}

<span class="hljs-selector-class">.text-center</span> {
    <span class="hljs-attribute">text-align</span>: center;
}
</code></pre>
<p>You never know when you are going to reuse it. Making it specific to a particular ID is a bad practice because HTML can only have one element that has the same ID. Coupling CSS to ID makes it not reusable. Only target it to a specific ID if you are sure that you are only going to use that specific CSS styling for that specific element.<br />Do notice that if you are using Bootstrap, some of the CSS utility classes are available out of the box.</p>
<h3 id="heading-3-use-css-pre-processor"><strong>3. Use CSS pre-processor</strong></h3>
<p>There are various CSS pre-processors available out there.</p>
<ol>
<li><p>Sass</p>
</li>
<li><p>LESS</p>
</li>
<li><p>Stylus</p>
</li>
<li><p>PostCSS</p>
</li>
</ol>
<p>For a small project, it might not be required. But when you are working on an enterprise-level project, styling consistencies are very important. CSS pre-processors help to keep your CSS <a target="_blank" href="https://en.wikipedia.org/wiki/Don%27t_repeat_yourself">DRY (Don't Repeat Yourself)</a> by allowing you to keep commonly used things (like colours and stylings) in one place and make them reusable. Here are how we can leverage the benefits of CSS pre-processors:</p>
<ol>
<li>Use variables. Variables allow you to reuse certain values like margin or colour throughout your application. Example in Sass (SCSS):</li>
</ol>
<pre><code class="lang-scss"><span class="hljs-variable">$blue</span>: <span class="hljs-number">#00f</span>;
<span class="hljs-variable">$default_margin</span>: <span class="hljs-number">1rem</span>;

<span class="hljs-selector-class">.bg-blue</span> {
    <span class="hljs-comment">// Background color will be *#00f* once processed</span>
    <span class="hljs-attribute">background-color</span>: <span class="hljs-variable">$blue</span>; 
}

<span class="hljs-selector-class">.container</span> {
    <span class="hljs-attribute">margin</span>: <span class="hljs-number">0</span> <span class="hljs-variable">$default_margin</span>;
}
</code></pre>
<ol start="2">
<li>Use Mixins for some reusable sets of styles. Example in LESS:</li>
</ol>
<pre><code class="lang-less"><span class="hljs-selector-class">.rounded-border</span> {
    <span class="hljs-attribute">border</span>: <span class="hljs-number">1px</span> solid;
    <span class="hljs-attribute">border-radius</span>: <span class="hljs-number">4px</span>;
}

<span class="hljs-comment">// To produce CSS for black border with rounded corner</span>
<span class="hljs-selector-class">.black-rounded-border</span> {
    <span class="hljs-attribute">border-color</span>: <span class="hljs-number">#000</span>;
    <span class="hljs-selector-class">.rounder-border</span>();
}

<span class="hljs-comment">// To produce CSS for blue border with rounded corner</span>
<span class="hljs-selector-class">.blue-rounded-border</span> {
    <span class="hljs-attribute">border-color</span>: <span class="hljs-number">#00f</span>;
    <span class="hljs-selector-class">.rounded-border</span>();
}
</code></pre>
<ol start="3">
<li>You can easily change the base variable for some UI frameworks like Bootstrap and Material. Changing the base variable prevents the need to override CSS to suit your branding, e.g., font size, padding, margin, and also default colours. You need to make sure that you import the pre-processed CSS file (e.g.: <code>.scss</code>), not the compiled <code>.css</code> file.</li>
</ol>
<h3 id="heading-4-avoid-important"><strong>4. Avoid <em>!important</em> !</strong></h3>
<p>Using <code>!important</code> can make your life hard. By default, any CSS property with <code>!important</code> takes precedence over any other CSS styling that is put into that particular component. It looks fine until you need to override that style that has <code>!important</code>. You will have to write a more specific CSS rule just so you can override it with another <code>!important</code>.</p>
<p>Instead, write CSS in either:</p>
<ol>
<li>Use specificity as much as possible. Rather than relying on <code>!important</code> tag, use any available parent's component or classes of the element to be the additional hook. e.g.:</li>
</ol>
<pre><code class="lang-css"><span class="hljs-selector-class">.form-control</span> {
    <span class="hljs-attribute">border</span>: <span class="hljs-number">1px</span> solid grey;
    <span class="hljs-attribute">border-radius</span>: <span class="hljs-number">0.5rem</span>;
}

<span class="hljs-selector-class">.squared</span><span class="hljs-selector-class">.form-control</span> {
    <span class="hljs-attribute">border-radius</span>: <span class="hljs-number">0</span>;
}

<span class="hljs-selector-class">.seamless</span> <span class="hljs-selector-class">.form-control</span> {
    <span class="hljs-attribute">border</span>: <span class="hljs-number">0</span>;
}
</code></pre>
<p>Don't fall into this rabbit hole of <code>!important</code> like the example below:</p>
<pre><code class="lang-css"><span class="hljs-selector-class">.form-control</span> {
    <span class="hljs-attribute">border</span>: <span class="hljs-number">1px</span> solid black<span class="hljs-meta">!important</span>;
}
<span class="hljs-selector-tag">input</span><span class="hljs-selector-class">.form-control</span> {
    <span class="hljs-attribute">border</span>: <span class="hljs-number">1px</span> solid blue<span class="hljs-meta">!important</span>;
}
<span class="hljs-selector-class">.parent-class</span> <span class="hljs-selector-tag">input</span><span class="hljs-selector-class">.form-control</span> {
    <span class="hljs-attribute">border</span>: <span class="hljs-number">1px</span> dotted green<span class="hljs-meta">!important</span>;
}
<span class="hljs-selector-id">#main-content</span> <span class="hljs-selector-class">.parent-class</span> <span class="hljs-selector-tag">input</span><span class="hljs-selector-class">.form-control</span> {
    <span class="hljs-attribute">border</span>: <span class="hljs-number">1px</span> dashed <span class="hljs-number">#eee</span><span class="hljs-meta">!important</span>;
}
</code></pre>
<ol start="2">
<li>If by any chance you are using some JavaScript framework like React, Vue, or Angular; you can use scoped CSS. Scoped CSS allows us to create a CSS specific to a particular component. It can be achieved by using some attributes appended to HTML elements.</li>
</ol>
<p>By having a scoped CSS, you have less specificity to worry about, since you don't necessarily need to override a CSS styling that is targeted for another component. All you need is to override base styling if required.</p>
<hr />
<p>These are a few things that I've used in projects to improve the quality of our CSS. Sometimes you might think that using a pre-processor like SCSS seems overkill for your project. However, the benefits of simplicity and consistency outweigh the learning curve and setup time. I hope you've learned something from these tips. Have you got any CSS tips that I've missed? Please do let me know in the comment section below.</p>
<p>P.S.: If you are ready to see the rabbit hole, <a target="_blank" href="https://wattenberger.com/blog/css-cascade">CSS Cascade</a> is a great resource about how CSS style 'cascades'.</p>
<p>Cheers!</p>
]]></description><link>https://devzilla.io/css-guide-for-dev-dummies</link><guid isPermaLink="true">https://devzilla.io/css-guide-for-dev-dummies</guid><category><![CDATA[CSS]]></category><category><![CDATA[scss]]></category><category><![CDATA[Less]]></category><dc:creator><![CDATA[Gabriel George]]></dc:creator></item><item><title><![CDATA[Different RxJs Maps]]></title><description><![CDATA[<p>Why there are various RxJs maps? What are they used for? What are the differences? Why can't I just use switchMap all the way? This was my thoughts before my friend, <a target="_blank" href="https://www.twitter.com/nthonymiller">Anthony Miller</a> enlightened me.</p>
<p>For an Angular developer that uses <a target="_blank" href="https://github.com/ngrx">NgRx</a>, we often get this dilemma of which type of map should we use upon receiving NgRx <code>action</code> for our <code>effect</code>. This issue also happens in any services or functions that rely on observable value change. I'm going to explain and give a small code sample to show you what is the difference of each.</p>
<h2 id="heading-switch-map"><strong>Switch Map</strong></h2>
<p><code>switchMap</code> is probably something that you see very often in a lot of code samples. It has a unique behaviour of switching from one to another as the name explains.<br />Theoretically speaking, what it does is: <em>when a next value pushed to the observable, it will cancel previous observable and take the current one instead.</em></p>
<h2 id="heading-merge-map"><strong>Merge Map</strong></h2>
<p><code>mergeMap</code> also lives up to its name. Its behaviour allows multiple observable values to be merged and each will run concurrently. Sometimes this behaviour is needed but proceeds very carefully with <code>mergeMap</code>. In many times, <code>mergeMap</code> causes race conditions. Use this map only if you know the incoming data will not override each other.</p>
<h2 id="heading-exhaust-map"><strong>Exhaust Map</strong></h2>
<p>When I first hear the word <code>exhaustMap</code>, I don't understand what is the concept of the naming. Then my friend explained it and it blew my mind! <code>exhaustMap</code> will prevent any data from going through if the previous observable is not yet completed. This means, whatever data you force into that observable will just get dropped. Not even queued.</p>
<h2 id="heading-concat-map"><strong>Concat Map</strong></h2>
<p>At this stage, you might think, <em>so there is no queueing system with observable data</em>? At ease crowd, <code>concatMap</code> comes to the rescue. As the name explains, <code>concatMap</code> will append observable data from one to another. It will create a queue that will run when the previous data has been completed.</p>
<hr />
<p>I have created a <a target="_blank" href="https://github.com/gabrielgeorge/RxJsMapSample">repository</a> on GitHub for these various map samples. It may not be the best looking, but it works. If you have any suggestions to make it look nicer and easier to visualise, please don't hesitate to give me feedback.</p>
]]></description><link>https://devzilla.io/different-rxjs-maps</link><guid isPermaLink="true">https://devzilla.io/different-rxjs-maps</guid><category><![CDATA[RxJS]]></category><category><![CDATA[Angular]]></category><dc:creator><![CDATA[Gabriel George]]></dc:creator></item><item><title><![CDATA["ng Update". Is it the long-awaited saviour?]]></title><description><![CDATA[<p>Most of us who have read the release blog for Angular 6 must be quite excited about the <code>ng update</code> command that was just introduced. But how does it cope with our existing project?</p>
<p>Initially, I was quite surprised that <code>ng update</code> I could easily upgrade my .NET Core 2.1 RC Angular SPA template without any hitch, except the fact I needed to install the TypeScript version <code>2.7.2</code> as one of the pre-requisite. Then the <code>ng update @angular/cli</code> blew my mind too, as it automatically converts my <code>angular-cli.json</code> and its content into the new <code>angular.json</code> with the new structure. Alas, the excitement didn't last long. I decided to give my existing project a try for <code>ng update</code>. The result? <em>Unsatisfying</em>.</p>
<p>Imagine that you're a kid in the first few queues in the front of a candy shop. Right at 10 AM sharp, the store is open. One by one people entered and brought out a bag of candies that you've been waiting for. Once you're in front of the door, you are not allowed to enter, because you have to be older than your age and have a certain height and weight requirements. <em>That is how it feels</em> when you realise that there are so many restrictions that prevent your <code>ng update</code> from working. Below is a snippet of my <code>ng update</code> command.</p>
<pre><code class="lang-bash">C:\<span class="hljs-built_in">source</span>\upgrade-sample (master -&gt; origin)
 ng update
    We analyzed your package.json, there are some packages to update:

      Name                               Version                  Command to update
     --------------------------------------------------------------------------------
      @angular/core                      5.2.2 -&gt; 6.0.1           ng update @angular/core
      rxjs                               5.5.2 -&gt; 6.1.0           ng update rxjs


    There might be additional packages that are outdated.
    Or run ng update --all to try to update all at the same time.


C:\<span class="hljs-built_in">source</span>\upgrade-sample (master -&gt; origin)
 ng update --all
                  Package <span class="hljs-string">"karma-jasmine-html-reporter"</span> has a missing peer dependency of <span class="hljs-string">"jasmine"</span> @ <span class="hljs-string">"&gt;=3"</span>.
                  Package <span class="hljs-string">"bootstrap"</span> has a missing peer dependency of <span class="hljs-string">"jquery"</span> @ <span class="hljs-string">"1.9.1 - 3"</span>.
                  Package <span class="hljs-string">"@angular/compiler-cli"</span> has an incompatible peer dependency to <span class="hljs-string">"typescript"</span> (requires <span class="hljs-string">"&gt;=2.7.2 &lt;2.8"</span>, would install <span class="hljs-string">"2.8.3"</span>).
                  Package <span class="hljs-string">"@ng-idle/core"</span> has an incompatible peer dependency to <span class="hljs-string">"@angular/common"</span> (requires <span class="hljs-string">"^4.0.0 || ^5.0.0"</span>, would install <span class="hljs-string">"6.0.1"</span>)
                  Package <span class="hljs-string">"@ngrx/router-store"</span> has an incompatible peer dependency to <span class="hljs-string">"@angular/common"</span> (requires <span class="hljs-string">"^5.0.0"</span>, would install <span class="hljs-string">"6.0.1"</span>)
                  Package <span class="hljs-string">"@ng-idle/keepalive"</span> has an incompatible peer dependency to <span class="hljs-string">"@angular/common"</span> (requires <span class="hljs-string">"^4.0.0 || ^5.0.0"</span>, would install <span class="hljs-string">"6.0.1"</span>)
                  Package <span class="hljs-string">"@ngrx/store-devtools"</span> has an incompatible peer dependency to <span class="hljs-string">"rxjs"</span> (requires <span class="hljs-string">"^5.5.0"</span>, would install <span class="hljs-string">"6.1.0"</span>)
                  Package <span class="hljs-string">"@ngrx/store"</span> has an incompatible peer dependency to <span class="hljs-string">"@angular/core"</span> (requires <span class="hljs-string">"^5.0.0"</span>, would install <span class="hljs-string">"6.0.1"</span>)
Invalid range: <span class="hljs-string">"&gt;=6.0.0-rc.0"</span>
</code></pre>
<p>Looking at the snippet, I sort of realised that <em>I will end up updating my package manually and one-by-one</em>. Such a tedious task.<br />Nevertheless, I believe one day <code>ng update</code> command will be very smart that it will be able to check all package dependencies and update the <code>package.json</code> smartly.</p>
]]></description><link>https://devzilla.io/ng-update-is-it-the-long-awaited-saviour</link><guid isPermaLink="true">https://devzilla.io/ng-update-is-it-the-long-awaited-saviour</guid><category><![CDATA[Angular]]></category><category><![CDATA[Angular]]></category><dc:creator><![CDATA[Gabriel George]]></dc:creator></item></channel></rss>