<?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 Manivel Arjunan on Medium]]></title>
        <description><![CDATA[Stories by Manivel Arjunan on Medium]]></description>
        <link>https://medium.com/@manivelarjunan?source=rss-da2debb45ba8------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*j34dhKdgtqzqVy7JSEJ1xQ@2x.jpeg</url>
            <title>Stories by Manivel Arjunan on Medium</title>
            <link>https://medium.com/@manivelarjunan?source=rss-da2debb45ba8------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 16:11:02 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@manivelarjunan/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[Lazy loading | Dynamic component loading | Code Splitting: React JS]]></title>
            <link>https://manivelarjunan.medium.com/lazy-loading-dynamic-component-loading-code-splitting-react-js-d41962cf69f3?source=rss-da2debb45ba8------2</link>
            <guid isPermaLink="false">https://medium.com/p/d41962cf69f3</guid>
            <category><![CDATA[lazy-loading]]></category>
            <category><![CDATA[dynamic-components]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[code-splitting]]></category>
            <category><![CDATA[suspense]]></category>
            <dc:creator><![CDATA[Manivel Arjunan]]></dc:creator>
            <pubDate>Sat, 30 Mar 2019 22:51:07 GMT</pubDate>
            <atom:updated>2019-03-30T22:51:07.105Z</atom:updated>
            <content:encoded><![CDATA[<p>What to expect from this article? Learn about below from this article.</p><ol><li>What is lazy loading/code splitting?</li><li>How does lazy loading help to increase the performance of the application?</li><li>Lazy loading component with HOC.</li><li>Lazy loading component with Suspense/Router.</li><li>Lazy loading component with Suspense but without Route.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SqPoIC3TeOMTS_lZXKQq7g.jpeg" /></figure><ol><li><strong>What is lazy loading/code splitting?</strong></li></ol><p>Loading the code bundle/ components dynamically When the user clicks on Route or based on user action. Downloading what your technique is called code splitting. Lazy loading also can be called as code splitting.</p><p><strong>2. How does lazy loading help to increase the performance of the application?</strong></p><p>Loading the entire bundle with all the code during the application initial load can increase application loading time and it decreases the application performance. Also, when your application contains different features but the user is not interested in all feature options. so loading the code where the user is not interested can decrease the application performance. Hence loading the component/ feature when the user required to increase the application performance. Lazy loading depends on web pack workflow configuration. Lazy loading matters a lot when downloading a bigger project.</p><p><strong>3. Lazy loading component with HOC(Higher Order Component)</strong></p><p>Async component(HOC) helps to load the component dynamically or whenever it is required.</p><pre>state = { component : null };</pre><p>Initially, the component will be set null in the state and component will be set dynamically like below.</p><pre>importComponent().then(cpm =&gt; {  <br>// it has default property to load component dynamically<br>// (cpm.default)                         this.setState({component:cpm.default});   <br>});<br></pre><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5e3c4dce7627fed143b5ee37114d2617/href">https://medium.com/media/5e3c4dce7627fed143b5ee37114d2617/href</a></iframe><p>Web packs prepare separate bundle for the dynamically loaded component. The application loads the Details page component whenever it is required.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8e90ed07273b715a2387df864ca172f2/href">https://medium.com/media/8e90ed07273b715a2387df864ca172f2/href</a></iframe><p><strong>4. Lazy loading component with Suspense/Router.</strong></p><p>Suspense helps to load the component dynamically when clicking on the route.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e6d7b7933c313c53e16295db78f230a7/href">https://medium.com/media/e6d7b7933c313c53e16295db78f230a7/href</a></iframe><p>fallback JSX code displays when code fails to load dynamically.</p><pre>fallback={&lt;span&gt;I am working on it ...&lt;/span&gt;}</pre><p><strong>5. Lazy loading component with Suspense but without Route.</strong></p><p>The component also can be loaded based on user click option.</p><pre>&lt;button onClick={this.loadHandler}&gt;Load component&lt;/button&gt;        </pre><pre>{this.state.loadComponent ?   <br>(&lt;Suspense fallback={&lt;span&gt;I am working on it ...&lt;/span&gt;}&gt;&lt;Details/&gt;&lt;/Suspense&gt;)          </pre><pre>: (&lt;Home /&gt;)}</pre><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1910b6176fd90d1cabbb9ae56840218a/href">https://medium.com/media/1910b6176fd90d1cabbb9ae56840218a/href</a></iframe><p>Below is the link for official documentation for lazy loading.</p><p><a href="https://reactjs.org/docs/code-splitting.html">Code-Splitting - React</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d41962cf69f3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Angular CLI + Angular console + VS code + Angular Augury]]></title>
            <link>https://manivelarjunan.medium.com/angular-cli-angular-console-vs-code-angular-augury-c34d8bde9643?source=rss-da2debb45ba8------2</link>
            <guid isPermaLink="false">https://medium.com/p/c34d8bde9643</guid>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[visual-studio-code]]></category>
            <category><![CDATA[angular-cli]]></category>
            <category><![CDATA[angular-console]]></category>
            <dc:creator><![CDATA[Manivel Arjunan]]></dc:creator>
            <pubDate>Sun, 20 Jan 2019 21:50:59 GMT</pubDate>
            <atom:updated>2019-01-20T21:50:59.491Z</atom:updated>
            <content:encoded><![CDATA[<p>What I will learn from this article?</p><ol><li>Angular CLI</li><li>Angular console</li><li>Visual studio code</li><li>Angular Augury</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/938/1*UhbQZzprBsOXxGe0Pbseyw.png" /><figcaption>Tools for Angular development</figcaption></figure><ol><li><strong>Angular CLI</strong></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*LiioBvZnxkEVHZzC1FQ8_A.png" /><figcaption>Angular CLI</figcaption></figure><p>The Angular CLI makes it easy to create an application that already works, right out of the box. It already follows Angular’s best practices! open the Node.js command prompt and run the below command to install Angular CLI.</p><pre>npm install -g @angular/cli</pre><p><strong><em>ng new</em></strong></p><p>Navigate to the folder path where you want to create Angular project then enter the below command.</p><pre>ng new my-project<br>cd my-project</pre><p><strong><em>npm install</em></strong></p><p>Run <strong><em>npm install </em></strong>to install all the dependencies what Angular project needs.</p><p><strong><em>ng serve</em></strong></p><p>Once all Angular dependencies installed successfully run the below command to start the application.</p><pre>ng serve</pre><p>open your favorite browser and view the created project by typing <strong>“<em>http://localhost:4200”</em></strong></p><p><strong><em>ng generate</em></strong></p><p>Generate components, routes, services and pipes with a simple command. The CLI will also create simple test shells for all of these. Run the below command in the project root directory to generate the home component</p><pre>ng generate component home<br>(or)<br>ng g c home</pre><pre>g - generate<br>c - component</pre><p><strong><em>Additional Commands:</em></strong></p><ul><li><a href="https://github.com/angular/angular-cli/wiki/lint">ng lint</a></li><li><a href="https://github.com/angular/angular-cli/wiki/test">ng test</a></li><li><a href="https://github.com/angular/angular-cli/wiki/e2e">ng e2e</a></li><li><a href="https://github.com/angular/angular-cli/wiki/build">ng build</a></li><li><a href="https://github.com/angular/angular-cli/wiki/config">ng get/ng set</a></li><li><a href="https://github.com/angular/angular-cli/wiki/doc">ng doc</a></li><li><a href="https://github.com/angular/angular-cli/wiki/xi18n">ng xi18n</a></li><li><a href="https://github.com/angular/angular-cli/wiki/update">ng update</a></li></ul><p>To know more about Angular CLI, click the below link.</p><p><a href="https://cli.angular.io/">Angular CLI</a></p><p><strong>2. Angular Console</strong></p><p>Not all developers can remember all Angular CLI commands and few developers feel CLI is quite intimidating. No worries Here is the Angular console and you can do more and more.</p><p><strong><em>Built by Developers for Developers.</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/981/1*Iq2E3GS5NZ7a9-sHibU6jg.png" /><figcaption>Angular console</figcaption></figure><blockquote>Spend less time looking up command line arguments, and more time shipping incredible products.</blockquote><p>The Angular CLI is immensely powerful and extensible. In fact, there are so many capabilities that it can often be hard to remember all of the different configuration options for every available command, or remember that certain features even exist!</p><p>Angular Console is, first and foremost, a more approachable way to work with what the Angular CLI already provides.</p><p><strong>What more you can do with Angular console?</strong></p><p><strong><em>2.1 Trivial code generation</em></strong></p><p>Leverage the CLI’s built-in generators for Components, Providers and more, all without having to remember a single command line flag.</p><p><strong><em>2.2 Run custom npm scripts</em></strong></p><p>As well as the standard `ng` commands, we automatically detect all of your custom npm scripts and allow you to run them with a single click.</p><p><strong><em>2.3 Discover and install extensions</em></strong></p><p>Search through a comprehensive list of official and community schematics to extend the power of the Angular CLI even further, and install them directly in the UI.</p><p><strong><em>2.4 Build CLI commands visually</em></strong></p><p>Using our visual form-driven UI, you get all of the flags and arguments for your chosen command available inline.</p><p><strong><em>2.5 Integrate terminal output</em></strong></p><p>As you compose and execute your commands in a visual way, you will also see your changes reflected in the inline terminal output in real-time.</p><p><strong><em>2.6 Import existing projects</em></strong></p><p>Create new Angular CLI projects from scratch, or import existing ones. We’ll even keep track of your recently opened projects so you can instantly access them again in future sessions.</p><p>To learn more about Angular console, click the below link.</p><p><a href="https://angularconsole.com/">Angular Console</a></p><p><strong>3. Microsoft visual studio code</strong></p><p>VS code is great for Angular Application development. VS code is free IDE, highly extensible, fast, developer friendly. Available for Mac, Windows, and Linux.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/744/1*tobiFVZ3BBXaQ_-7BDEM-A.png" /></figure><p>Install Angular Essentials( Click on <strong><em>view </em></strong>in the menu then click in <strong><em>extensions</em></strong>). Angular Essentials helps to enhance IDE to work better for Angular.</p><p><a href="https://code.visualstudio.com/download">Download Visual Studio Code - Mac, Linux, Windows</a></p><p><strong>4. Angular Augury</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/860/1*281bmCmJQSGZ33CaIBWRfA.png" /><figcaption>Angular Augury</figcaption></figure><p><strong><em>What is Augury?</em></strong></p><p>Augury is the most used Developer Tool extension for debugging and profiling Angular applications inside the Google Chrome and Mozilla Firefox browsers.</p><p><strong><em>Why use Augury?</em></strong></p><p>Augury helps Angular developers visualize the application through component trees and visual debugging tools. Developers get immediate insight into their application structure, change detection and performance characteristics.</p><p><strong><em>Install and analysis Angular Augury</em></strong></p><p>Chrome Augury extension</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1016/1*DqLcqUTy3HAEK7cw7PxnpA.png" /></figure><p>Debugging and profiling Angular application.</p><ol><li>Run the Angular application with the <strong><em>ng serve</em></strong> command</li><li>Open the developer tool and click on Augury tab</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/935/1*4DQdf2I_IdVUJb_Q1mZJjw.png" /><figcaption>Augury developer extension</figcaption></figure><p>To learn more about Angular Augury, click the below link.</p><p><a href="https://augury.rangle.io/">Angular Augury</a></p><p>Alright, it’s a time to get our hands dirty.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c34d8bde9643" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Angular 7 + unit testing + code coverage]]></title>
            <link>https://manivelarjunan.medium.com/angular-7-unit-testing-code-coverage-5c7a238315b6?source=rss-da2debb45ba8------2</link>
            <guid isPermaLink="false">https://medium.com/p/5c7a238315b6</guid>
            <category><![CDATA[code-coverage]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[debug]]></category>
            <category><![CDATA[unit-testing]]></category>
            <dc:creator><![CDATA[Manivel Arjunan]]></dc:creator>
            <pubDate>Sun, 09 Dec 2018 04:58:27 GMT</pubDate>
            <atom:updated>2018-12-29T19:34:53.986Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*Kp5funHPTBEscIeEdho81g.jpeg" /></figure><ol><li>What is unit testing?</li><li>Why unit testing is important?</li><li>Angular 7 application configuration for unit testing, debug and code coverage.</li><li>Basic Component unit testing</li><li>What is a destructuring assignment and why not to use beforeEach.</li><li>Synchronous and Async service(Observables implementation)unit testing using TestBed, Async, fakeAsync and tick utilities.</li><li>What is isolation testing?</li><li>How to test HTTP service?</li><li>What are fdescribe and fit (Skip the test(s) execution).</li><li>Why put spec file next to the file it tests?</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MWqPifWUjzu9rYNKWJDzGA.png" /><figcaption>Jasmine &amp; karma</figcaption></figure><ol><li><strong>What is unit testing?</strong></li></ol><p><strong>Unit testing</strong> is a <strong>software</strong> development process in which the smallest testable parts of an application, called units, are individually and independently scrutinized for proper operation. <strong>Unit testing</strong> can be done manually but it is often automated.</p><p><strong>2. Why unit testing is important?</strong></p><ol><li>Unit testing Analyze the code behavior (expected and unexpected changes).</li><li>It behaves as a safeguard against breaking changes. One of the best ways to keep your project bug free is through a test suite.</li><li>Makes developers feel guilty free on their code changes.</li><li>It also reveals the design mistakes.</li></ol><p><strong>3. Angular 7 application configuration for unit testing debug and code coverage.</strong></p><p><strong><em>3.1 configuration</em></strong></p><p>The Angular CLI downloads and install everything you need to test an Angular application with the <a href="https://jasmine.github.io/">Jasmine test framework</a>.</p><p>When you create a component, directive, pipe etc through <a href="https://cli.angular.io/">Angular CLI</a>, spec file will be created automatically with the default test suite.</p><p>Once you created a project through Angular CLI/ <a href="https://medium.com/@manivel45/git-stop-learn-and-feel-good-1332815679e7">cloning from a remote repository</a>, go to project root directory and run the below command to run the test suite.</p><pre>ng test</pre><p>and you will see the below logs in the console.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xBmukVvshjDnL-hod4BKMA.png" /><figcaption>ng test logs</figcaption></figure><p>Also, <strong><em>ng test</em></strong> opens up chrome window to view the success and failed test cases.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1013/1*AQIMO1UaOBisP7nXumCWKQ.png" /></figure><p><strong><em>3.2 debug</em></strong></p><p>Debug specs in the browser in the same way that you debug an application.</p><ol><li>Reveal the karma browser window (hidden earlier).</li><li>Click the DEBUG button; it opens a new browser tab and re-runs the tests.</li><li>Open the browser’s “Developer Tools” (Ctrl+Shift+I on windows; command + option + I in OSX).</li><li>Pick the “sources” section.</li><li>Open the app.component.spec.ts test file (Control/Command-P, then start typing the name of the file).</li><li>Set a breakpoint in the test.</li><li>Refresh the browser, and it stops at the breakpoint.</li></ol><p>Below diagram depicts how to debug.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VPFkA3MS288x4o0pdjSdZQ.png" /><figcaption>Debug the spec file</figcaption></figure><p><strong><em>3.3 code coverage</em></strong></p><p>If you want to create code-coverage reports every time you run the test suite, you can set the following option in the CLI configuration file, angular.json:</p><pre>&quot;test&quot;:{ <br>  &quot;options&quot;:{   <br>  &quot;codeCoverage&quot;: true <br>  }<br>}</pre><p>(or) run the below command in the project root directory.</p><pre>ng test --code-coverage</pre><p>Whenever test suite executed successfully, you will see a <strong><em>“coverage”</em></strong> folder in project root directory.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/335/1*bIEirPQtSkrfoXUdlxO75A.png" /><figcaption>coverage folder</figcaption></figure><p>Open the index.html file in your favorite browser to view the test case coverage for all the files in the project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/943/1*Avy4P_UEMmKs7EHmAO5AzA.png" /><figcaption>istanbul code coverage report</figcaption></figure><p><strong>4. Component unit testing with angular testing utilities.</strong></p><p><strong>What is TestBed?</strong></p><p>The <strong><em>TestBed </em></strong>is the most important of the Angular testing utilities. It creates a dynamically-constructed Angular test module that emulates an Angular @NgModule.<strong><em>TestBed.configureTestingModule()</em></strong> method takes a metadata object that can have most of the properties of an <strong><em>@NgModule</em></strong>.</p><p>The <strong><em>TestBed</em></strong> API consists of static class methods that either update or reference a <em>global</em> instance of the <strong><em>TestBed</em></strong>.</p><p>Internally, all static methods cover methods of the current runtime <strong><em>TestBed</em></strong> instance, which is also returned by the <strong>get<em>TestBed()</em></strong> function.</p><p>Call <strong><em>TestBed</em></strong> methods <em>within</em> a beforeEach() to ensure a fresh start before each individual test.</p><pre>beforeEach(async(() =&gt; {</pre><pre>TestBed.configureTestingModule({</pre><pre>declarations: [AppComponent, UserComponent, UserAsyncComponent]</pre><pre>}).compileComponents();</pre><pre>}));</pre><p><strong>What is a component fixture?</strong></p><p>The <strong><em>TestBed.createComponent&lt;T&gt;</em></strong> creates an instance of the component <strong><em>T</em></strong> and returns a strongly typed for that component.</p><p>The <strong><em>ComponentFixture </em></strong>properties and methods provide access to the component, its DOM representation, and aspects of its Angular environment.</p><p>The <em>fixture</em> methods cause Angular to perform certain tasks on the component tree. Call these methods to trigger Angular behavior in response to simulated user action.</p><p><strong>What is DebugElement?</strong></p><p>The <strong><em>DebugElement </em></strong>provides crucial insights into the component&#39;s DOM representation.</p><p>From the test root component’s <strong><em>DebugElement </em></strong>returned by <strong><em>fixture.debugElement</em></strong>, you can walk (and query) the fixture&#39;s entire element and component subtrees.</p><p><strong><em>Basic component testing</em></strong></p><p>A component, unlike all other parts of an Angular application, combines an HTML template and a TypeScript class. The component truly is the template and the class <em>working together </em>and to adequately test a component, you should test that they work together as intended.</p><p>Such tests require creating the component’s host element in the browser DOM, as Angular does, and investigating the component class’s interaction with the DOM as described by its template.</p><p>Here is the example of Basis component testing using Angular TestBed utility.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/80f1f775556281972ec6cc48a1c27c83/href">https://medium.com/media/80f1f775556281972ec6cc48a1c27c83/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c45f9af9a818192eb801d4225f443369/href">https://medium.com/media/c45f9af9a818192eb801d4225f443369/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/25a50becebd694043e5d00b11bea84ff/href">https://medium.com/media/25a50becebd694043e5d00b11bea84ff/href</a></iframe><p><strong>5. What is a destructuring assignment(setup method) and why is it better than using beforeEach()</strong></p><p>Note that, in above spec file I used<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment"> destructing assignment</a> instead of BeforeEach. Most test suites call <strong><em>beforeEach()</em></strong> to set the preconditions for each <strong><em>it()</em></strong> test and rely on the <strong><em>TestBed</em></strong> to create classes and inject services.</p><p>There’s another school of testing that never calls <strong><em>beforeEach()</em></strong> and prefers to create classes explicitly rather than use the <strong><em>TestBed</em></strong>.The <strong><em>setup()</em></strong> function returns an object literal with the variables, such as app, that a test might reference. You don’t define semi-global variables (e.g., let app, fixture ) in the body of the <strong><em>describe()</em></strong>. Then each test invokes <strong><em>setup()</em></strong> in its first line, before continuing with steps that manipulate the test subject and assert expectations.</p><blockquote>Angular team recommands to use <strong><em>setup </em></strong>function instead of traditional <strong><em>beforeEach()</em></strong></blockquote><p>Here is the spec file using <strong><em>traditional </em></strong>beforeEach().</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/de977f8f574f08cbd728767fbe2e70e0/href">https://medium.com/media/de977f8f574f08cbd728767fbe2e70e0/href</a></iframe><p><strong>Synchronous service unit test</strong></p><p>Testing synchronous service which is injected in a component. Injecting the real service rarely works well as most dependent services are difficult to create and control.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/084e285e8f3d82b359a3d9d610b97cff/href">https://medium.com/media/084e285e8f3d82b359a3d9d610b97cff/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/834fb07c8b71fe4d6887cb0270f7f636/href">https://medium.com/media/834fb07c8b71fe4d6887cb0270f7f636/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c73d31afdc84b46be72f0db7cca8a490/href">https://medium.com/media/c73d31afdc84b46be72f0db7cca8a490/href</a></iframe><p>Injecting service in a spec file.</p><pre>const userService = fixture.debugElement.injector.get(UserService);</pre><blockquote>Prefer spies as they are usually the easiest way to mock services.</blockquote><p>Spy the service and return the custom values.</p><pre>const mockUser = { name: &#39;Mannie&#39; };</pre><pre>spyOn(userService, &#39;getUser&#39;).and.returnValue(mockUser);</pre><p>Update the properties, run the change detection. You must tell the <strong><em>TestBed </em></strong>to perform data binding by calling <strong><em>fixture.detectChanges()</em></strong></p><pre>fixture.detectChanges();</pre><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ef0466a00e395af93862dee05a0b22e0/href">https://medium.com/media/ef0466a00e395af93862dee05a0b22e0/href</a></iframe><p><strong>Async service(Observables implementation) unit testing</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cf900344df3c95a84b0c688c5db7fc9a/href">https://medium.com/media/cf900344df3c95a84b0c688c5db7fc9a/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8c0bec0a9cf7d04e7a2d47b8fc7e5b25/href">https://medium.com/media/8c0bec0a9cf7d04e7a2d47b8fc7e5b25/href</a></iframe><p>Creating Async service using Observable, observable returns username after 2 milliseconds</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b68a4bd8533e82539d87e37fe35df240/href">https://medium.com/media/b68a4bd8533e82539d87e37fe35df240/href</a></iframe><p><strong><em>tick, fakeAsync</em></strong> testing utilities are used to test Async service.</p><p><strong><em>fakeAsync </em></strong>— wrap <strong><em>“it” </em></strong>with<strong><em> </em></strong>fakeAsync to create Async environment for test.it allows running Async task and it simulates like Async call running in the browser.</p><p><strong><em>tick — </em></strong>Wait for Async calls finishes and successfully to access the data. Simulates the passage of time and the completion of pending asynchronous activities by flushing both <em>timer</em> and <em>micro-task</em> queues within the <em>fakeAsync test zone</em>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c6faac3666afcce32a0fce1e8e72610b/href">https://medium.com/media/c6faac3666afcce32a0fce1e8e72610b/href</a></iframe><p><strong>7. Isolation testing</strong></p><p>Pipes are easy to test without the Angular testing utilities. These are tests of the pipe <em>in isolation</em>. Files which are doesn’t require angular dependency can be tested without angular testing utilities.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b6351ce45c2463c40e53ee4ab74b3768/href">https://medium.com/media/b6351ce45c2463c40e53ee4ab74b3768/href</a></iframe><p>Creating a test for pipe and it is an isolation testing since it doesn’t depend on Angular and doesn’t use testing utilities.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3f375958231342f1be5f31c2fec04c42/href">https://medium.com/media/3f375958231342f1be5f31c2fec04c42/href</a></iframe><p><strong>8. Testing HTTP service</strong></p><p>Data services that make HTTP calls to remote servers typically inject and delegate to the Angular <strong><em>HTTPClient</em></strong> service for XHR calls.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/413a86e0a7a37007bed2f59fc341a42e/href">https://medium.com/media/413a86e0a7a37007bed2f59fc341a42e/href</a></iframe><p><strong>9. fdescribe and fit ( skip the test or run only specific tests)</strong></p><p>Add <strong><em>fdescribe </em></strong>to run the test for a spec file or a test suite. It skips all other files or runs test for the specified file.</p><pre><strong>f</strong>describe(&#39;UserComponent&#39;, () =&gt; {</pre><pre>beforeEach(async(() =&gt; {</pre><pre>TestBed.configureTestingModule({</pre><pre>declarations: [UserComponent]</pre><pre>});</pre><p>Add <strong><em>fit </em></strong>to run the test for <strong><em>“it”</em></strong> level. It skips all other tests and runs only one test.</p><pre>fit(&#39;should create app component&#39;, () =&gt; {</pre><pre>const { component } = setup();</pre><pre>expect(component).toBeTruthy();</pre><pre>});</pre><p><strong>10. Why put spec file next to the file it tests?</strong></p><p>It’s a good idea to put unit test spec files in the same folder as the application source code files that they test:</p><ul><li>Such tests are easy to find.</li><li>You see at a glance if a part of your application lacks tests.</li><li>Nearby tests can reveal how a part works in context.</li><li>When you move the source (inevitable), you remember to move the test.</li><li>When you rename the source file (inevitable), you remember to rename the test file.</li></ul><p>Below is the link for Github projects. It contains all the configuration and code explained above.</p><p><a href="https://github.com/manivelarjunan/Angular7-unit-testing">manivelarjunan/Angular7-unit-testing</a></p><p>Below is the link for Angular official documentation for unit testing.</p><p><a href="https://angular.io/guide/testing">Angular</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5c7a238315b6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Git Merge vs Rebase + Reset vs Revert vs Checkout]]></title>
            <link>https://manivelarjunan.medium.com/git-merge-vs-rebase-reset-vs-revert-vs-checkout-dd5674d0e18a?source=rss-da2debb45ba8------2</link>
            <guid isPermaLink="false">https://medium.com/p/dd5674d0e18a</guid>
            <category><![CDATA[git]]></category>
            <category><![CDATA[gitflow]]></category>
            <category><![CDATA[gitlab]]></category>
            <category><![CDATA[github-pages]]></category>
            <category><![CDATA[github]]></category>
            <dc:creator><![CDATA[Manivel Arjunan]]></dc:creator>
            <pubDate>Fri, 16 Nov 2018 04:49:30 GMT</pubDate>
            <atom:updated>2018-12-14T00:10:09.910Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*6wNDPd2jGNi7z8v_sdirMQ.jpeg" /></figure><p>What I will learn from this page? is it worth spending my valuable time here? Lets’ me see</p><ol><li>What is Git?</li><li>Why Git is better than SVN?</li><li>Git Workflow</li><li>What is Git bash and why to use it?</li><li>Git staging, committing and pushing to the repository.</li><li>Merge vs Rebase</li><li>Reset vs revert vs check out</li><li>what is .gitIgnore</li></ol><iframe src="https://drive.google.com/viewerng/viewer?url=https%3A//www.atlassian.com/dam/jcr%3A8132028b-024f-4b6b-953e-e68fcce0c5fa/atlassian-git-cheatsheet.pdf&amp;embedded=true" width="600" height="780" frameborder="0" scrolling="no"><a href="https://medium.com/media/cc85aca5989683c1ef04a3a9853ed328/href">https://medium.com/media/cc85aca5989683c1ef04a3a9853ed328/href</a></iframe><p><strong>Git most useful commands. (</strong>Navigate to the project root directory in Git Bash tool and type the below commands.<strong>)</strong></p><p><a href="https://git-scm.com/download">Downloads</a></p><p>Cloning remote repository. Navigate to the workspace where do you want to clone the project.</p><pre>git init</pre><pre><em>// git-init - Create an empty Git repository or reinitialize an existing one</em></pre><pre>git clone <a href="https://github.com/libgit2/libgit2.git">https://github.com/libgit2/libgit2.git</a></pre><pre>// Clone the entire remote respository to local repository</pre><p>To know the status of the files in each step.</p><pre>git status</pre><p>Revert the changes in the local before staging the files.</p><pre>git stash</pre><p>List the commits</p><pre>git log <br>git log --oneline ( Displays the commits in one line)<br>git log --graph ( Displays the commits as a graph)</pre><p>Stage the changes</p><pre>git add . <br>git add -A<br>git add *.java ( Adds only java files)</pre><p>Commit the files in the local repository.</p><pre>git commit -m &quot;my first change&quot;</pre><pre><em>&quot;my first change&quot; - git commit message</em></pre><p>Stage and commit the files in a single command</p><pre>git commit -a -m &quot;my second change&quot;</pre><p>Push the changes to a remote repository</p><pre>git push origin feature/add-landing-page<br><em>&quot;add-landing-page&quot; - Name of the branch</em></pre><p>Fetching the changes/Branches to the local git repository</p><pre>git fetch</pre><p>Pulling the changes from the remote repository and merging to the local workspace</p><pre>git pull</pre><p>Pulling the changes from the master branch and merging to the local branch</p><pre>git pull origin master</pre><pre><em>Let&#39;s assume that currently you are working on branch called feature/add-landing-page</em></pre><p>Switching between the branches ( If your workspace is master)</p><pre>git checkout feature/add-main-page</pre><pre><em>// switching back to maste branch</em></pre><pre>git checkout master</pre><p>Revert the committed changes.</p><pre>git revert f5c5cac0033439c17ebf905d4391dc0705dbd5f1</pre><pre><strong>Run git log first, it will display the list of committed changes then do the revert.</strong></pre><pre><em>f5c5cac0033439c17ebf905d4391dc0705dbd5f1 </em>- each commit creates the unique commit id</pre><p>Reset the committed changes.</p><pre>git reset f5c5cac0033439c17ebf905d4391dc0705dbd5f1</pre><pre><strong>Run git log first, it will display the list of committed changes then do the reset.</strong></pre><p>Deleting local and remote branch</p><pre>git branch -d branch_name<br>git branch -D branch_name<br>// Deleting local branch</pre><pre>git push &lt;remote_name&gt; --delete &lt;branch_name&gt;</pre><pre>git push &lt;remote_name&gt; :&lt;branch_name&gt;</pre><pre>// Deleting remote branch</pre><ol><li><strong>What is Git?</strong></li></ol><p>Git is a free and open source distributed version control system designed to handle everything from small to the very large project with speed and efficiency.</p><p>Git was developed by the famous Linux creator <strong>Linus Torvalds. </strong>Let’s make him famous.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*ARShVNmxWF2u3weFTuLbVQ.jpeg" /><figcaption><strong>Linus Torvalds</strong></figcaption></figure><p><strong>2.Why Git is better than SVN and Why Git is so complex?</strong></p><p>In Git the default development branch is called master and all changes are committed into this branch. <strong><em>It Gives every developed their own local copy of their entire project</em></strong>. This isolated environment lets each developer work independently of all other changes to a project without bothering what is changed in the master branch.</p><p>Git gives you access to Git’s robust branching and merging model.<strong><em> Switching between the branch is so easy</em></strong>. Git Avoids <strong><em>merging the conflicts</em></strong> code to the master branch. In addition to being distributed, Git has been designed with performance, security, and flexibility in mind.</p><p><strong>3.Git Workflow</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*l5KcB2M44_3gde-JASG1rw.png" /><figcaption>Git init and clone workflow</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*gZX2Cs-To3k1h63hHhPPcw.jpeg" /><figcaption>Git workflow</figcaption></figure><p><strong>4.Why Git Bash</strong></p><p>Git Bash is a command line interface tool for Git. It Provides a more detailed description in each step of Git workflow. All famous IDEs integrated git flow and it differs with each tool. Each IDE has its own way of understanding the Git flow. Git Bash is the solution for all in one.</p><p>Git Bash command doesn’t change whether you are using any of the below web-based tools.</p><p><a href="https://github.com/"><strong>GitHub</strong></a> is a development platform inspired by the way you work. From open source to business, you can host and review code, manage projects, and build software alongside millions of the other developers.</p><p><a href="https://bitbucket.org/"><strong>Bitbucket</strong></a> is more than just Git code management. Bitbucket gives teams one place to plan projects, collaborate on code, test and deploy.</p><p><a href="https://about.gitlab.com/"><strong>GitLab</strong></a> is a web-based Git-repository manager with wiki and issue-tracking, using an open-source license, developed by GitLab Inc.</p><p><strong>5. Git Staging, commit and push</strong></p><p>Once you made the changes you can run the below commands to push the changes to the remote repository.</p><pre>git status</pre><pre>git add .</pre><pre>git commit -m &quot;third commit message&quot;</pre><pre>git push origin feature/add-landing-page</pre><p><strong>6.Git Merge vs Rebase</strong></p><p>In Git, there are two ways to integrate changes from one branch into another: the merge and rebase.</p><p><strong><em>Merge:</em></strong></p><p>The easiest option is to merge the master branch into the feature branch. This creates a new <strong><em>“merge commit”</em></strong> in the feature branch that ties together the histories of both branches, giving you a branch structure that looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*TdDDyrrHnfh1a1s7et6M5A.png" /><figcaption>merge branch</figcaption></figure><pre>git checkout master</pre><pre>git merge branch</pre><pre>// git command to merge the branch(feature branch - add-header)<br>Ex: git merge add-header</pre><p>Merge is always a forward-moving change record. Merging is nice because it’s a <em>non-destructive</em> operation. The existing branches are not changed in any way. This avoids all of the potential pitfalls of rebasing (discussed below).</p><p><strong><em>Rebase:</em></strong></p><p>Merge is nice but on the other hand, this also means that the feature branch will have an extraneous merge commit every time you need to incorporate upstream changes.</p><p>The first thing to understand about Git rebase is that it solved the same problem as git merge. Both of these commands are designed to integrate changes from one branch into another branch-they just do it in very different ways. Rebasing is the process of <strong><em>moving or combining a sequence of commits to a new base commit</em></strong>. The major benefit of rebasing is that you get a much cleaner project history. First, it eliminates the <strong><em>unnecessary merge commits required by git merge</em></strong>.</p><p>Rebasing works by <strong><em>transferring each local commit to the updated master branch one at a time</em></strong>. This means that you catch merge conflicts on a commit-by-commit basis rather than resolving all of them in one massive merge commit. In turn, this makes easier to figure out where bugs were introduced and if necessary to roll back changes with minimal impact on the project.</p><pre>git checkout branch</pre><pre>git rebase master</pre><pre>git checkout master</pre><pre>git merge branch</pre><pre>// git command to merge the branch(feature branch - add-header)<br>Ex: git merge add-header</pre><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*QqZwxKbSlsQBZl-AhICbBA.gif" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*LMl69zL2Vp0UkKUv5n7Rig.gif" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*ZQkmDS3ULsIQdfXteYdo7w.png" /></figure><p><strong>7.Reset vs Revert vs Checkout</strong></p><p>If you are using <a href="https://www.atlassian.com/software/jira">JIRA </a>it requires you to mention the story number when committing the changes then push the changes but sometimes we tend to forget to mention the story number and it causes you to not to push the changes to the repository. You might have seen this kind of error in git bash window.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*ZwZBP4oAe899w5QVCL7iyQ.png" /><figcaption>git push rejected</figcaption></figure><p>so, in this kind of situation, you can reset or revert or check out the changes. Before doing this do git log to know in which commit you missed to mention the JIRA story number.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*7vQ1EZE3giv450UuDCdSkA.png" /><figcaption>git log — list of git commits</figcaption></figure><p><strong><em>Reset</em></strong></p><p>A reset is an operation that takes a specified commit and resets the “three trees” to match the state of the repository at that specified commit. A reset can be invoked in three different modes which correspond to the three trees.</p><p>git reset can be done in file level and commit level as well.</p><p>In addition to moving the current branch, you can also get git reset to alter the staged snapshot and/or the working directory by passing it one of the following flags:</p><ul><li>--soft – The staged snapshot and working directory are not altered in any way.</li><li>--mixed – The staged snapshot is updated to match the specified commit, but the working directory is not affected. This is the default option.</li><li>--hard – The staged snapshot and the working directory are both updated to match the specified commit.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*NHyhjBIHdHY9bckck4yUMA.png" /><figcaption>git reset</figcaption></figure><pre>git reset f5c5cac0033439c17ebf905d4391dc0705dbd5f1</pre><pre>// f5c5cac0033439c17ebf905d4391dc0705dbd5f1 - commit you want to reset</pre><p>Revert</p><p>Revert is an operation that takes a specified commit and creates a new commit which inverses the specified commit. git revert can only be run at a commit level and has no file level functionality.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*qL0yublANmKQ0Uj7BIUEOg.png" /><figcaption>git revert</figcaption></figure><pre>git revert f5c5cac0033439c17ebf905d4391dc0705dbd5f1</pre><pre>// f5c5cac0033439c17ebf905d4391dc0705dbd5f1 - commit you want to revert</pre><p><strong><em>checkout</em></strong></p><p>You can also check out arbitrary commits by passing the commit reference instead of a branch. This does the exact same thing as checking out a branch: it moves the HEAD reference to the specified commit. For example, the following command will check out the grandparent of the current commit:</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*MSiqpr4eLIVlC5f7DMiYLg.png" /><figcaption>checkout</figcaption></figure><pre>git checkout f5c5cac0033439c17ebf905d4391dc0705dbd5f1</pre><pre>// f5c5cac0033439c17ebf905d4391dc0705dbd5f1 - commit you want to checkout</pre><blockquote>git <strong><em>revert </em></strong>is the best command to use in case of an issue because it will not lose the commits whereas reset orphans the commits.</blockquote><p><strong>Git Reset vs Revert vs Checkout reference</strong></p><p>The table below sums up the most common use cases for all of these commands. Be sure to keep this reference handy, as you’ll undoubtedly need to use at least some of them during your Git career.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*pQencNUMPARN6_rG3fdvKg.png" /><figcaption><strong>Git Reset vs Revert vs Checkout reference</strong></figcaption></figure><p><strong>8.gitIgnore</strong></p><p>All the project will have <a href="https://git-scm.com/docs/gitignore">.gitignore</a> file in project disk space. We can specify intentionally untracked files to ignore.</p><p>Click the below link to learn more.</p><p><a href="https://www.atlassian.com/git/tutorials">Git Tutorials and Training | Atlassian Git Tutorial</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dd5674d0e18a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Configuring Angular 7 project with SASS, bootstrap, and Angular material design.]]></title>
            <link>https://manivelarjunan.medium.com/configuring-angular-7-project-with-sass-bootstrap-and-angular-material-design-69b0f033dc04?source=rss-da2debb45ba8------2</link>
            <guid isPermaLink="false">https://medium.com/p/69b0f033dc04</guid>
            <category><![CDATA[angular-material]]></category>
            <category><![CDATA[sass]]></category>
            <category><![CDATA[bootstrap-4]]></category>
            <dc:creator><![CDATA[Manivel Arjunan]]></dc:creator>
            <pubDate>Sun, 04 Nov 2018 21:25:44 GMT</pubDate>
            <atom:updated>2019-01-29T16:58:59.409Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Configuring Angular 7 project with SASS, bootstrap, and Angular material design</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/826/1*_MjYV3fAnXOQHhVjMUC8VA.png" /><figcaption>Angular + Styles</figcaption></figure><p>What I will learn from this article?</p><ol><li><em>How to create Angular 7 application with SCSS style files.</em></li><li>Converting existing Angular CSS project to SCSS style sheet.</li><li><em>Configuring bootstrap CSS.</em></li><li><em>Configure angular material design.</em></li></ol><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fstackblitz.com%2Fedit%2Fangular-material-bootstrap-css%3Fembed%3D1&amp;url=https%3A%2F%2Fstackblitz.com%2Fedit%2Fangular-material-bootstrap-css&amp;image=https%3A%2F%2Fc.staticblitz.com%2Fassets%2Ficon-664493542621427cc8adae5e8f50d632f87aaa6ea1ce5b01e9a3d05b57940a9f.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/c025574c15886352a8bc46c097440dc4/href">https://medium.com/media/c025574c15886352a8bc46c097440dc4/href</a></iframe><p><strong>1. Creating Angular application with SCSS style files.</strong></p><p>Normally, when we run ng new my-app, our app will have .css files. To get the CLI to generate .scss files (or .sass/.less) is an easy matter.</p><p>Run the below command in the project root directory.</p><pre>ng new my-first-app --style=scss</pre><p>You can also set the --style flag with the following:</p><ul><li>--style=scss</li><li>--style=sass</li><li>--style=less</li></ul><p><strong>2. Converting existing Angular CSS project to SCSS style sheet.</strong></p><p>If you’ve already created your Angular CLI app with the default .css files, it will take a bit more work to convert it over. You can tell Angular to start processing Sass files with the following command</p><p>From Angular 6 to set new style on existing project with CLI:</p><p>Run the below command in the project root directory.</p><pre>ng config schematics.@schematics/angular:component.styleext scss</pre><p>Or modify directly into angular.json manually:</p><pre>&quot;schematics&quot;: {<br>      &quot;@schematics/angular:component&quot;: {<br>      &quot;styleext&quot;: &quot;scss&quot;<br>    }<br>}</pre><h4>Changing the CSS Files to Sass</h4><p>The Angular CLI will start processing Sass files now. However, it doesn’t go through the process of converting your already existing .css files to .scss files. <strong>You&#39;ll have to make the conversion manually</strong>.</p><p><strong>3. Configuring bootstrap</strong></p><p>Run the below command in the project root directory.</p><pre>npm install --save bootstrap</pre><p>Now that we have Bootstrap, let’s look at how we can include the basic CSS file. This is an easy process by adding the bootstrap.css file to our .angular-cli.json config:</p><pre>&quot;styles&quot;: [<br>  &quot;../node_modules/bootstrap/dist/css/bootstrap.css&quot;,<br>  &quot;sass/styles.scss&quot;<br>],</pre><h4>NOTE: Sometimes adding (../) works.</h4><pre>&quot;styles&quot;: [<br>  &quot;node_modules/bootstrap/dist/css/bootstrap.css&quot;,<br>  &quot;sass/styles.scss&quot;<br>],</pre><ul><li><a href="https://sass-guidelin.es/#the-7-1-pattern">Sass Guidelines</a></li><li><a href="https://scotch.io/tutorials/using-sass-with-the-angular-cli">Using Sass with the Angular CLI</a></li></ul><h3><a href="https://scotch.io/tutorials/using-sass-with-the-angular-cli#toc-importing-sass-files-into-angular-components">Importing Sass Files Into Angular Components</a></h3><p>We have new _variables.scss and _mixins.scss files that we will probably want to use in our components. In other projects, you may be used to having access to your Sass variables in all locations since your Sass is compiled by a task runner.</p><p>In the Angular CLI, all components are self-contained and so are their Sass files. In order to use a variable from within a component’s Sass file, you’ll need to import the _variables.scss file.</p><p>One way to do this is to @import with a relative path from the component. This may not scale if you have many nested folders or eventually move files around.</p><pre>// src/app/app.component.scss<br><br>@import &#39;~sass/variables&#39;;<br><br>// now we can use those variables!</pre><p><strong>4. Configuring Angular material design.</strong></p><p>Angular material is part of the package developed by Angular team which gives set of a pre-built component. It is not a styling package it is an angular package. It uses Google’s material design. It is easy to add and can be customized with our own CSS/SASS styles. Using the Angular CLI( version 6+) ng add command will update your Angular project with the correct dependencies, perform configuration changes and execute initialization code.</p><p>Run the below command in the project root directory.</p><pre>ng add @angular/material</pre><p>once it is installed successfully, you will see this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/645/1*R3TFqNoZMea2Adu0y5kQ-A.png" /><figcaption>Styles in angular.json file</figcaption></figure><p>Angular material uses Animation. So, below module will be added in the app.module.ts file.</p><h4>import { BrowserAnimationsModule } from ‘@angular/platform-browser/animations’;</h4><p>Angular material module will not be available by default to save the space of the application. You have to import whatever module you needed from ‘@angular/material’;</p><p>See the angular application with material design on the <a href="https://angular-material-bootstrap-css.stackblitz.io/">stakblitz URL</a>.</p><p>Read more on material design</p><ul><li><a href="https://material.angular.io/">Angular Material</a></li><li><a href="https://academind.com/learn/angular/angular-material-a-thorough-guide/">Angular Material - A Thorough Guide</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=69b0f033dc04" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding the Observable(rxjs) and creating Observable with Angular 7]]></title>
            <link>https://manivelarjunan.medium.com/understanding-the-observable-rxjs-and-creating-observable-with-angular-7-8fae4746874f?source=rss-da2debb45ba8------2</link>
            <guid isPermaLink="false">https://medium.com/p/8fae4746874f</guid>
            <category><![CDATA[reactivex]]></category>
            <category><![CDATA[rxjava]]></category>
            <category><![CDATA[observables]]></category>
            <category><![CDATA[angular-4]]></category>
            <dc:creator><![CDATA[Manivel Arjunan]]></dc:creator>
            <pubDate>Thu, 01 Nov 2018 03:37:09 GMT</pubDate>
            <atom:updated>2019-02-20T15:43:11.488Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Angular 7: Understanding &amp; Creating Observables</strong> <strong>(rxjs 6)</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7-NY3dB5UqZAXt_LcacjZg.jpeg" /></figure><p>Learn about below from this article.</p><ol><li><em>What is observable, observer and subscribe?</em></li><li><em>Why observable is better than Javascript promises?</em></li><li>How to create simple Observable.</li><li>Creating Custom observable.</li><li>Unsubscribe the observable.</li><li>Observable operators.</li><li><strong>What is observable?</strong></li></ol><p>In ReactiveX an observer subscribes to an Observable. Observable follows the observer design pattern. Then that observer reacts to whatever item or sequence of items the Observable emits. This pattern facilitates concurrent operations because it does not need to block while waiting for the Observable to emit objects, but instead, it creates a sentry in the form of an observer that stands ready to react appropriately at whatever future time the Observable does so.</p><p>In other documents and other contexts, what we are calling an “observer” is sometimes called a “subscriber,” “watcher,” or “reactor.” This model, in general, is often referred to as the <a href="http://en.wikipedia.org/wiki/Reactor_pattern">“reactor pattern”</a>.</p><blockquote>Read more on <a href="http://reactivex.io/">observable</a>.</blockquote><p><strong>2. Why observable is better than Javascript promises?</strong></p><p>Javascript promises still work well with Angular and Observable is an alternative and Angular embraces it. What makes Observable better over promises.</p><ol><li>Using observer operators are the major advantage of using Observable.</li><li>Most operators operate on an Observable and return an Observable. This allows you to apply these operators one after the other, in a chain. Each operator in the chain modifies the Observable that results from the operation of the previous operator.</li><li>We can set how many times we can retry the failure calls.</li><li>Catch the failure and throw the user friendly error message.</li><li>Cancel the request.</li><li>Interceptors returns the Observable(both request and response).</li><li>Define the response type(text/JSON). By default,it returns the JSON response.</li><li>Angular itself uses Observable a lot.</li></ol><p><strong>3. Creating simple observable</strong></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fstackblitz.com%2Fedit%2Fcreate-observable%3Fembed%3D1&amp;url=https%3A%2F%2Fstackblitz.com%2Fedit%2Fcreate-observable&amp;image=https%3A%2F%2Fc.staticblitz.com%2Fassets%2Ficon-664493542621427cc8adae5e8f50d632f87aaa6ea1ce5b01e9a3d05b57940a9f.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/67403c641a1e32f9e9a5fdb65405335d/href">https://medium.com/media/67403c641a1e32f9e9a5fdb65405335d/href</a></iframe><p><strong>4. Creating custom observable?</strong></p><p>Observable can emit the data package with below methods.</p><p><strong><em>onNext,onError and onCompleted</em></strong></p><p>The subscribe method is how you connect an observer to an Observable. Your observer implements some subset of the following methods:</p><p>onNextAn Observable calls this method whenever the Observable emits data package. This method takes as a parameter the data package emitted by the Observable.</p><p>onErrorAn Observable calls this method to indicate that it has failed to generate the expected data or has encountered some other error. It will not make further calls to onNext or onCompleted.</p><p>The onError method takes as its parameter an indication of what caused the error.onCompletedAn Observable call this method after it has called onNext for the final time if it has not encountered any errors.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fstackblitz.com%2Fedit%2Fangular-create-custom-observable%3Fembed%3D1&amp;url=https%3A%2F%2Fstackblitz.com%2Fedit%2Fangular-create-custom-observable&amp;image=https%3A%2F%2Fc.staticblitz.com%2Fassets%2Ficon-664493542621427cc8adae5e8f50d632f87aaa6ea1ce5b01e9a3d05b57940a9f.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/1ae7ec78131667eb3e2cdab86089a6fc/href">https://medium.com/media/1ae7ec78131667eb3e2cdab86089a6fc/href</a></iframe><p><strong>5. Unsubscribe the Observable</strong></p><p>When you are leaving the component but Observable has not been completed, it is a good practice to unsubscribe the Observable to avoid memory leakage. Angular built-in function is smart enough to clear the memory but it is advised to unsubscribe all the observables. Unsubscription can be implemented in onDestroy Angular life cycle hook.</p><p><em>ngOnDestroy(){</em></p><p><em>this.customSubscrition.unsubscribe();</em></p><p><em>}</em></p><p><strong>6. Observable operators</strong></p><p>Operators( filter, map etc) are transforming the data into something that what we want. Since operators simply return new observables, you can of course also chain these Operators.</p><p><a href="http://reactivex.io/documentation/operators.html">Read more on operators.</a></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fstackblitz.com%2Fedit%2Fangular-observable-operators%3Fembed%3D1&amp;url=https%3A%2F%2Fstackblitz.com%2Fedit%2Fangular-observable-operators&amp;image=https%3A%2F%2Fc.staticblitz.com%2Fassets%2Ficon-664493542621427cc8adae5e8f50d632f87aaa6ea1ce5b01e9a3d05b57940a9f.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/f6928f984a466a94c413545fc31ce9dc/href">https://medium.com/media/f6928f984a466a94c413545fc31ce9dc/href</a></iframe><p>Subject follows the observer design pattern and used in Angular cross-component communication. Read more on here.</p><p><a href="https://medium.com/@manivel45/event-emitter-vs-subject-cross-component-communication-8934376605e1">Event Emitter vs Service vs Subject( Cross component communication in Angular 6)</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8fae4746874f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Given a list of numbers and a target, return whether any two numbers from the list add up to…]]></title>
            <link>https://manivelarjunan.medium.com/given-a-list-of-numbers-and-a-target-return-whether-any-two-numbers-from-the-list-add-up-to-b09207f920f4?source=rss-da2debb45ba8------2</link>
            <guid isPermaLink="false">https://medium.com/p/b09207f920f4</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[google-interview]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[algorithms]]></category>
            <dc:creator><![CDATA[Manivel Arjunan]]></dc:creator>
            <pubDate>Fri, 19 Oct 2018 03:52:54 GMT</pubDate>
            <atom:updated>2018-10-19T04:04:08.465Z</atom:updated>
            <content:encoded><![CDATA[<p>Given a list of numbers and a target, return whether any two numbers from the list add up to target. (Google interview question)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*JlrA1-_4-_mtc30-QXPyrw.jpeg" /></figure><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FXKu_SEDAykw%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DXKu_SEDAykw&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FXKu_SEDAykw%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/98307ea0780c1f8e29bb3c2e0bd7c609/href">https://medium.com/media/98307ea0780c1f8e29bb3c2e0bd7c609/href</a></iframe><p>This problem can be solved in several different ways.</p><p><strong>Brute force way:</strong></p><p>Brute force way would involve a nested iteration to check for every pair of numbers:</p><p>Input [10, 15, 3, 7], Target : 17</p><p>if yes then return true else false.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/53cb7549f790a85fdab95d49f0e026fc/href">https://medium.com/media/53cb7549f790a85fdab95d49f0e026fc/href</a></iframe><p><strong>Linear solution:</strong></p><p>Another way is to use a set to remember the numbers we’ve seen so far. Then for a given number, we can check if there is another number that, if added, would sum to k. This would be O(N) since lookups of sets are O(1) each.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9ef27a9d02eacfc7f91014c9a23804c9/href">https://medium.com/media/9ef27a9d02eacfc7f91014c9a23804c9/href</a></iframe><p><strong>Best solution:</strong></p><p>Yet another solution involves sorting the list. We can then iterate through the list and run a binary search on K — array[i]. Since we run a binary search on N elements, this would take O(N log N) with O(1) space.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2675577f1f2e9792bb7cb10f53733626/href">https://medium.com/media/2675577f1f2e9792bb7cb10f53733626/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b09207f920f4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Event Emitter vs Service vs Subject( Cross component communication in Angular 6)]]></title>
            <link>https://manivelarjunan.medium.com/event-emitter-vs-subject-cross-component-communication-8934376605e1?source=rss-da2debb45ba8------2</link>
            <guid isPermaLink="false">https://medium.com/p/8934376605e1</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[rxjs]]></category>
            <category><![CDATA[angular-6]]></category>
            <dc:creator><![CDATA[Manivel Arjunan]]></dc:creator>
            <pubDate>Wed, 15 Aug 2018 02:33:26 GMT</pubDate>
            <atom:updated>2019-02-20T03:10:31.609Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*JlrA1-_4-_mtc30-QXPyrw.jpeg" /></figure><p>This article explains what are all the different option to implement cross component communication in Angular and what is the best options to implement it.</p><ol><li>What is Event Emitter and how to implement?</li><li>What is the service and how to implement?</li><li>What is Subject and how to implement?</li><li>Which one is better for cross-component communication in angular 6?</li></ol><h4>Event Emitter:</h4><p>Event-emitter is imported from “@anguar/core” package. It is used in directives and components to emit custom events synchronously or asynchronously and register handlers for those events by subscribing to an instance. Event emitter is a generic type, it can take any additional information.</p><p>It uses ‘@Output’ and ‘@Input’ decorators.</p><p>Emit the event.</p><pre><em>@Output() postData = new EventEmitter()</em></pre><p>listen to the event</p><pre>@Input() listPost = [];</pre><p>Below is the sample post message application implemented with event emitter.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fstackblitz.com%2Fedit%2Fangular-post-app-event-emitter%3Fembed%3D1&amp;url=https%3A%2F%2Fstackblitz.com%2Fedit%2Fangular-post-app-event-emitter&amp;image=https%3A%2F%2Fc.staticblitz.com%2Fassets%2Ficon-664493542621427cc8adae5e8f50d632f87aaa6ea1ce5b01e9a3d05b57940a9f.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/3a7310914040dff59e239444237fd4e0/href">https://medium.com/media/3a7310914040dff59e239444237fd4e0/href</a></iframe><p><strong><em>Service</em></strong></p><p>Services are a great way to share information among classes that don’t know each other.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fstackblitz.com%2Fedit%2Fangular-service-to-service-communication%3Fembed%3D1&amp;url=https%3A%2F%2Fstackblitz.com%2Fedit%2Fangular-service-to-service-communication&amp;image=https%3A%2F%2Fc.staticblitz.com%2Fassets%2Ficon-664493542621427cc8adae5e8f50d632f87aaa6ea1ce5b01e9a3d05b57940a9f.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/a4784a1f5416ebcd1ffd72e9c3c452b0/href">https://medium.com/media/a4784a1f5416ebcd1ffd72e9c3c452b0/href</a></iframe><p><strong>Subject</strong></p><p>A subject is imported from “rxjs” package. A subject is an active listener. it triggers with next(). A subject is a special kind of observable. It maintains the stream of data which is maintained actively. A subject is an observer and observable. Event emitter built on top of the subject. It is good practice to use subject. Subscribe to consume the data. Unsubscribe in case of leaving the component to avoid the memory leak.</p><p>Emit the data:</p><p>// next triggers the value.</p><p>this.sharedserive.chatMessageAdded.next(postMessage.value);</p><p>Subscribe the data:</p><p>this.sharedService.chatMessageAdded.subscribe((data) =&gt; {</p><p>this.listPost.push(data);</p><p>});</p><p>Learn more about Subject: <a href="http://reactivex.io/documentation/subject.html"><em>http://reactivex.io/documentation/subject.html</em></a></p><p>Below is the sample post message application implemented with “rxjs” Subject.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fstackblitz.com%2Fedit%2Fangular-post-app-rxjs-subject%3Fembed%3D1&amp;url=https%3A%2F%2Fstackblitz.com%2Fedit%2Fangular-post-app-rxjs-subject&amp;image=https%3A%2F%2Fc.staticblitz.com%2Fassets%2Ficon-664493542621427cc8adae5e8f50d632f87aaa6ea1ce5b01e9a3d05b57940a9f.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/8077c7349db7a13865ca7f1b7ed68d65/href">https://medium.com/media/8077c7349db7a13865ca7f1b7ed68d65/href</a></iframe><h4>Which one is better in the case of cross-component communication?</h4><blockquote>Event emitter is built on top of the subject. A subject is better to use in case of cross-component communication.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8934376605e1" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>