<?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 Abhishek Kumar on Medium]]></title>
        <description><![CDATA[Stories by Abhishek Kumar on Medium]]></description>
        <link>https://medium.com/@abhishek300830?source=rss-1b175f9403be------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*pcLXNF0OClFuGYmy</url>
            <title>Stories by Abhishek Kumar on Medium</title>
            <link>https://medium.com/@abhishek300830?source=rss-1b175f9403be------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 19 May 2026 13:10:43 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@abhishek300830/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[RxJS Angular: Guide to Operators]]></title>
            <link>https://medium.com/@abhishek300830/rxjs-angular-guide-to-operators-4822edbdbdd0?source=rss-1b175f9403be------2</link>
            <guid isPermaLink="false">https://medium.com/p/4822edbdbdd0</guid>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[rxjs]]></category>
            <category><![CDATA[rxjs-operators]]></category>
            <dc:creator><![CDATA[Abhishek Kumar]]></dc:creator>
            <pubDate>Tue, 14 Nov 2023 14:16:51 GMT</pubDate>
            <atom:updated>2023-11-16T05:12:14.504Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Tj7GVWQfALcLT2MBxpe4KQ.jpeg" /></figure><p>Commonly used RxJS Operators are:</p><h3>1. pipe Function:</h3><p>The pipe function is used to chain multiple operators together to create a sequence of operations applied to an Observable.</p><pre>import { of } from &#39;rxjs&#39;;<br>import { map, filter } from &#39;rxjs/operators&#39;;<br><br>// Example: Using pipe to chain map and filter operators<br>const source = of(1, 2, 3, 4, 5);<br><br>const modified = source.pipe(<br>  map(value =&gt; value * 2),<br>  filter(value =&gt; value &gt; 5)<br>);<br><br>modified.subscribe(result =&gt; console.log(result)); // Output: 6, 8, 10</pre><h3>2. map Operator:</h3><p>The map operator transforms values emitted by an Observable by applying a function to each value and emitting the transformed result.</p><pre>import { of } from &#39;rxjs&#39;;<br>import { map } from &#39;rxjs/operators&#39;;<br><br>// Example: Using map to transform values<br>const source = of(1, 2, 3, 4, 5);<br><br>const mapped = source.pipe(<br>  map(value =&gt; value * 2)<br>);<br><br>mapped.subscribe(result =&gt; console.log(result)); // Output: 2, 4, 6, 8, 10</pre><h3>3. filter Operator:</h3><p>The filter operator selectively emits values from an Observable based on a specified condition.</p><pre>import { of } from &#39;rxjs&#39;;<br>import { filter } from &#39;rxjs/operators&#39;;<br><br>// Example: Using filter to emit only even numbers<br>const source = of(1, 2, 3, 4, 5);<br><br>const evenNumbers = source.pipe(<br>  filter(value =&gt; value % 2 === 0)<br>);<br><br>evenNumbers.subscribe(result =&gt; console.log(result)); // Output: 2, 4</pre><h3>4. mergeMap Operator:</h3><p>The mergeMap operator projects each value emitted by an Observable into an inner Observable and merges the resulting Observables into one.</p><pre>import { fromEvent } from &#39;rxjs&#39;;<br>import { mergeMap } from &#39;rxjs/operators&#39;;<br><br>// Example: Using mergeMap with mouse events<br>const source = fromEvent(document, &#39;click&#39;);<br><br>const coordinates = source.pipe(<br>  mergeMap(event =&gt; fromEvent(document, &#39;mousemove&#39;))<br>);<br><br>coordinates.subscribe(event =&gt; console.log(event.clientX, event.clientY));</pre><h3>5. debounceTime Operator:</h3><p>The debounceTime operator emits a value from the source Observable only after a specified time has passed without new values being emitted.</p><pre>import { fromEvent } from &#39;rxjs&#39;;<br>import { debounceTime } from &#39;rxjs/operators&#39;;<br><br>// Example: Using debounceTime for search functionality<br>const searchInput = document.getElementById(&#39;searchInput&#39;);<br><br>const searchObservable = fromEvent(searchInput, &#39;input&#39;);<br><br>searchObservable<br>  .pipe(debounceTime(300))<br>  .subscribe(() =&gt; {<br>    // Perform search operation after 300ms of no input<br>    // Call search function here<br>  });<br><br></pre><h3>6. catchError Operator:</h3><p>The catchError operator intercepts errors emitted by an Observable and allows handling or recovering from those errors by returning a new Observable or a default value.</p><pre>import { of, throwError } from &#39;rxjs&#39;;<br>import { catchError } from &#39;rxjs/operators&#39;;<br><br>// Example: Using catchError to handle errors<br>const source = of(&#39;Data&#39;);<br><br>const modifiedSource = source.pipe(<br>  mergeMap(data =&gt; {<br>    if (data !== &#39;Data&#39;) {<br>      return throwError(&#39;Invalid data&#39;);<br>    }<br>    return of(data);<br>  }),<br>  catchError(error =&gt; {<br>    console.error(&#39;Error:&#39;, error);<br>    return of(&#39;Default data&#39;); // Provide default data in case of error<br>  })<br>);<br><br>modifiedSource.subscribe(result =&gt; console.log(result)); // Output: &#39;Default data&#39;</pre><h3>7. BehaviorSubject:</h3><p>A BehaviorSubject in RxJS maintains the &quot;current&quot; value and emits it to subscribers when they subscribe to it. It retains the most recent value emitted to new subscribers.</p><pre>import { BehaviorSubject } from &#39;rxjs&#39;;<br><br>// Example: Creating and using a BehaviorSubject<br>const subject = new BehaviorSubject&lt;string&gt;(&#39;Initial Value&#39;);<br><br>// Subscribe to the BehaviorSubject<br>subject.subscribe(value =&gt; console.log(&#39;Subscriber A:&#39;, value)); // Output: Initial Value<br><br>// Next value<br>subject.next(&#39;Updated Value&#39;);<br><br>// Subscribe again<br>subject.subscribe(value =&gt; console.log(&#39;Subscriber B:&#39;, value)); // Output: Updated Value</pre><h3>8. tap Operator:</h3><p>The tap operator allows performing side effects for an Observable without modifying the emitted values. It is commonly used for debugging, logging, or executing additional actions.</p><pre>import { of } from &#39;rxjs&#39;;<br>import { tap } from &#39;rxjs/operators&#39;;<br><br>// Example: Using tap for logging without affecting emitted values<br>const source = of(1, 2, 3, 4, 5);<br><br>const tapped = source.pipe(<br>  tap(value =&gt; console.log(&#39;Value:&#39;, value))<br>);<br><br>tapped.subscribe(result =&gt; console.log(result)); // Output: Logs each value without affecting emitted values</pre><h3>9. switchMap Operator:</h3><p>The switchMap operator is used to map each value emitted by the source Observable to a new inner Observable. It cancels any previous inner Observables if a new value is emitted.</p><pre>import { fromEvent } from &#39;rxjs&#39;;<br>import { switchMap } from &#39;rxjs/operators&#39;;<br><br>// Example: Using switchMap with mouse events<br>const source = fromEvent(document, &#39;click&#39;);<br><br>const coordinates = source.pipe(<br>  switchMap(event =&gt; fromEvent(document, &#39;mousemove&#39;))<br>);<br><br>coordinates.subscribe(event =&gt; console.log(event.clientX, event.clientY));</pre><h3>Conclusion:</h3><p>These examples showcase various RxJS operators and features, demonstrating how they manipulate data streams, handle errors, perform side effects, and manage asynchronous operations within Angular or any RxJS-based application.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4822edbdbdd0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[RxJS in Angular: A Simple Guide]]></title>
            <link>https://medium.com/@abhishek300830/rxjs-in-angular-a-simple-guide-45be803faacb?source=rss-1b175f9403be------2</link>
            <guid isPermaLink="false">https://medium.com/p/45be803faacb</guid>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[rxjs]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Abhishek Kumar]]></dc:creator>
            <pubDate>Tue, 14 Nov 2023 13:59:03 GMT</pubDate>
            <atom:updated>2023-11-16T05:08:45.746Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/872/1*D-aEC7jvoWARTgCSWZ_7VQ.png" /></figure><p>RxJS, or Reactive Extensions for JavaScript, is a powerful library for handling asynchronous data streams in Angular applications. It makes handling things like getting data from servers, dealing with forms, and responding to user actions smoother and more manageable.</p><p>At its core, RxJS revolves around observables, observers, and operators. Observables represent sequences of events or values that can be observed over time. Observers are consumers of these observables that react to the emitted values. Operators are functions that enable manipulation, filtering, combining, and transforming of these observable streams.</p><h3>Observables</h3><p>Observables are the foundation of RxJS. They can emit multiple values asynchronously, and interested parties can subscribe to these observables to receive these values.</p><p>Let’s create a simple observable in an Angular component:</p><pre>import { Observable } from &#39;rxjs&#39;;<br><br>const myObservable = new Observable&lt;number&gt;(observer =&gt; {<br>  observer.next(1);<br>  observer.next(2);<br>  observer.next(3);<br>  setTimeout(() =&gt; {<br>    observer.next(4);<br>    observer.complete();<br>  }, 1000);<br>});<br><br>myObservable.subscribe({<br>  next: value =&gt; console.log(value),<br>  error: err =&gt; console.error(err),<br>  complete: () =&gt; console.log(&#39;Observable completed&#39;)<br>});</pre><h3>Operators</h3><p>Operators allow us to transform, filter, combine, and manipulate the data emitted by observables.</p><p><a href="https://medium.com/@abhishek300830/rxjs-angular-guide-to-operators-4822edbdbdd0">To understand Operator in Details, click here…</a></p><pre>import { from } from &#39;rxjs&#39;;<br>import { map, filter } from &#39;rxjs/operators&#39;;<br><br>const numbers = from([1, 2, 3, 4, 5]);<br><br>numbers.pipe(<br>  filter(num =&gt; num % 2 === 0),<br>  map(num =&gt; num * num)<br>).subscribe(result =&gt; console.log(result));</pre><h3>HTTP Requests</h3><p>Using RxJS in Angular HTTP module allows for handling of HTTP requests.</p><p>For all HttpClient methods, the method doesn&#39;t begin its HTTP request until you call subscribe () on the observable the method returns. Calling subscribe () triggers execution of the observable and causes HttpClient to compose and send the HTTP request to the server.</p><p>Think of these observables as <em>blueprints</em> for actual HTTP requests.</p><pre>import { HttpClient } from &#39;@angular/common/http&#39;;<br>constructor(private http: HttpClient) {}<br>getData() {<br>  return this.http.get&lt;any&gt;(&#39;https://api.example.com/data&#39;)<br>    .subscribe(data =&gt; {<br>      // Handle data here<br>    });<br>}</pre><h3>Event Handling</h3><p>RxJS simplifies event handling in Angular components:</p><pre>import { fromEvent } from &#39;rxjs&#39;;<br>ngOnInit() {<br>  const button = document.getElementById(&#39;myButton&#39;);<br>  const buttonClick = fromEvent(button, &#39;click&#39;);<br>  <br>  buttonClick.subscribe(() =&gt; {<br>    // Handle button click<br>  });<br></pre><h3>Conclusion</h3><p>RxJS is a crucial part of Angular development, empowering developers to build reactive, responsive, and scalable applications. Understanding observables, observers, and operators is essential for the full power of RxJS in Angular.</p><p>This article has provided an overview of RxJS in Angular along with examples showcasing its usage in different scenarios. Experimenting with these concepts and exploring more operators will further enhance your ability to write clean and efficient code in Angular applications.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=45be803faacb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Asynchronous JavaScript with async/await.]]></title>
            <link>https://medium.com/@abhishek300830/asynchronous-javascript-with-async-await-e7884ccfddc5?source=rss-1b175f9403be------2</link>
            <guid isPermaLink="false">https://medium.com/p/e7884ccfddc5</guid>
            <category><![CDATA[asynchronous]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[async-await-javascript]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Abhishek Kumar]]></dc:creator>
            <pubDate>Mon, 30 Oct 2023 18:22:40 GMT</pubDate>
            <atom:updated>2023-10-31T11:17:11.657Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vsZ7fYFnKwjK2xhh2VpyEA.png" /></figure><p>JavaScript, a widely used language for web development, can become complex when dealing with asynchronous tasks. Fortunately, JavaScript introduced: `async` and `await` that make handling asynchronous operations much easier. In this article, we’ll explore these concepts in detail.</p><p><strong>Understanding Asynchronous JavaScript</strong></p><p>Before we dive into `async` and `await`, let’s grasp the idea of “asynchronous” in JavaScript. Asynchronous tasks are those that take time to complete, like fetching data from a website or waiting for user input. In the past, JavaScript used callbacks for managing these tasks, but there are issues with Callbacks like Callback Hell and Inversion of Control. we will cover these topics in upcoming articles.</p><p><strong>Using `async` Functions</strong></p><p>An `async` function is just like a regular JavaScript function, but it’s designed to handle asynchronous tasks. When you declare a function as `async`, it returns something called a “promise” to handle asynchronous work.</p><p><em>Here’s a simple example how to create an `async` function:</em></p><pre>async function fetchData() {<br>  // Code that does asynchronous task<br>  return result;<br>}</pre><p>In this code, `fetchData` is an `async` function that can handle asynchronous tasks like loading data from a website. When this function is called, it returns a promise to manage the results of the asynchronous task.</p><p><strong>Using `await` to Wait for Promises</strong></p><p>The `await` keyword is used inside `async` functions to tell JavaScript to pause and wait for a promise to finish. It’s like saying, “Hey, I need this promise to be done before I continue.”</p><p><em>Here’s a simple example how you use `await` in function:</em></p><pre>async function fetchData() {<br>  const result = await someAsyncFunction();<br>  return result;<br>}</pre><p>In this example, `await` makes JavaScript wait for the `someAsyncFunction` promise to complete before continuing with the rest of the code. This helps us work with the result of the asynchronous operation without getting tangled in callbacks.</p><p><strong>Practical Example</strong></p><p>Let’s look at a practical example of fetching data from an API using `async` and `await:</p><pre>async function fetchUserData(userId) {<br>  try {<br>    const response = await fetch(`https://api.example.com/users/${userId}`);<br>    if (!response.ok) {<br>      throw new Error(&#39;Failed to fetch user data&#39;);<br>    }<br>    const userData = await response.json();<br>    return userData;<br>  } catch (error) {<br>    console.error(error);<br>    return null;<br>  }<br>}</pre><p>In this code, the `fetchUserData` function gets user data from an API using `fetch`. The `await` keyword ensures the code waits for the API response. If something goes wrong, it catches errors and handles them nicely.</p><p><strong>Conclusion</strong></p><p>Async/await is a useful feature in JavaScript that simplifies handling asynchronous code. By using `async` functions and `await`, you can write code that looks almost like regular, step-by-step code while still taking full advantage of JavaScript’s ability to manage multiple tasks at once. It makes coding less complicated and more understandable, especially when dealing with web applications and tasks that require waiting for things to happen.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e7884ccfddc5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[DOM Manipulation Using JavaScript]]></title>
            <link>https://medium.com/@abhishek300830/dom-manipulation-using-javascript-7aeed5380ed7?source=rss-1b175f9403be------2</link>
            <guid isPermaLink="false">https://medium.com/p/7aeed5380ed7</guid>
            <category><![CDATA[dom-manipulation]]></category>
            <category><![CDATA[document-object-model]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Abhishek Kumar]]></dc:creator>
            <pubDate>Tue, 24 Oct 2023 19:30:56 GMT</pubDate>
            <atom:updated>2023-10-30T06:39:05.529Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*f3TkNwP8MwwLaQoe7qrHJg.png" /></figure><p>In web development, DOM manipulation with JavaScript is a fundamental skill. Whether you’re building a simple webpage or a full-fledged web application, understanding how to interact with the Document Object Model (DOM) is essential for creating dynamic and interactive projects.</p><p>Here, we’ll explore different methods for DOM manipulation using JavaScript.</p><p><strong>In this article I will be referring to this HTML code.</strong></p><p>In this HTML code all classes and id are defined which is used in code snippets below.</p><pre>&lt;!DOCTYPE html&gt;<br>&lt;html lang=&quot;en&quot;&gt;<br>   &lt;head&gt;<br>      &lt;meta charset=&quot;UTF-8&quot; /&gt;<br>      &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot; /&gt;<br>      &lt;title&gt;Document&lt;/title&gt;<br>   &lt;/head&gt;<br>   &lt;body&gt;<br>      &lt;div class=&quot;class-name&quot; id=&quot;element-id&quot;&gt;<br>         This is a div.<br>      &lt;/div&gt;<br>      &lt;p&gt;This is a Paragraph Tag.&lt;/p&gt;<br>      &lt;img src=&quot;./profile.jpg&quot; alt=&quot;my-profile-photo&quot; class=&quot;my-image&quot; /&gt;<br>      &lt;button id=&quot;my-button&quot;&gt;&lt;/button&gt;<br>   &lt;/body&gt;<br>&lt;/html&gt;</pre><p><strong>1. Selecting DOM Elements</strong></p><p>Before you can manipulate the DOM, you need to select the elements you want to work with. JavaScript provides several methods for selecting DOM elements:</p><p><em>Select an element by ID.</em></p><pre>const elementById = document.getElementById(&quot;element-id&quot;);</pre><p><em>Select elements by class name.</em></p><pre>const elementsByClass = document.getElementsByClassName(&quot;class-name&quot;);</pre><p><em>Select elements by tag name.</em></p><pre>const elementsByTag = document.getElementsByTagName(&quot;p&quot;);</pre><p><em>Select an element using a CSS selector.</em></p><pre>const elementByQuery = document.querySelector(&quot;.class-name&quot;);</pre><p><em>Select multiple elements using a CSS selector.</em></p><pre>const elementsByQueryAll = document.querySelectorAll(&quot;.name&quot;);</pre><p>These are different ways to select any HTML element through which we are able to add dynamic effects using JavaScript.</p><p><strong>2. Modifying Element Content</strong></p><p>You can change the content of DOM elements using properties like <strong>‘text Content’</strong> and <strong>‘inner HTML’</strong> and <strong>‘inner TEXT’</strong>:</p><p><em>Change the text content of any HTML element.</em></p><pre>const elementId = document.getElementById(&quot;element-id&quot;);<br>elementId.textContent = &quot;New Text&quot;;</pre><p><em>Change the HTML content using inner HTML.</em></p><pre>const elementId = document.getElementById(&quot;element-id&quot;);<br>elementId.innerHTML = &quot;&lt;strong&gt;Bold Text&lt;/strong&gt;&quot;;</pre><p><em>Change the HTML content using inner TEXT.</em></p><pre>const elementId = document.getElementById(&quot;element-id&quot;);<br>elementId.innerTEXT = &quot;New Text&quot;;</pre><p><strong>3. Modifying Element Attributes</strong></p><p>You can also change attributes of HTML elements using JavaScript. First of all we fetch the element and then we change the attribute of that element. For example, to change the source of an image element:</p><p><em>Change the source of an image using JavaScript.</em></p><pre>const imageElement = document.getElementById(&quot;my-image&quot;);<br>imageElement.src = &quot;new-image.jpg&quot;;</pre><p><strong>4. Creating and Appending DOM Elements</strong></p><p>You can create and append new DOM elements to the document. firstly, we created a new element and then we modified it’s attributes. Here’s an example of creating a new paragraph element and appending it to the body:</p><pre>const newParagraph = document.createElement(&quot;p&quot;);<br>newParagraph.textContent = &quot;This is a new paragraph.&quot;;<br>document.body.appendChild(newParagraph);</pre><p><strong>5. Adding Event Listeners</strong></p><p>You can use JavaScript to add event listeners to DOM elements to respond to user actions:</p><pre>const buttonElement = document.getElementById(&quot;my-button&quot;);</pre><p><em>Add a click event listener to the button.</em></p><pre>buttonElement.addEventListener(&quot;click&quot;, function () {<br>alert(&quot;Button clicked!&quot;);<br>});</pre><p><strong>6. Modifying CSS Styles</strong></p><p>JavaScript can be used to modify CSS styles for elements. You can change element styles by accessing their `style` property:</p><p><em>Change the background of HTML element.</em></p><pre>const styledElement = document.getElementById(&quot;element-id&quot;);<br>styledElement.style.backgroundColor = &quot;blue&quot;;</pre><p><em>Change the font size.</em></p><pre>styledElement.style.fontSize = &quot;16px&quot;;</pre><h3>Conclusion</h3><p>In this article, you learned how to select, modify, and interact with DOM elements to create dynamic and interactive web experiences. Whether you’re building a simple webpage or a complex web application. Practice these with different use cases to enhance your proficiency in DOM manipulation with JavaScript.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7aeed5380ed7" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>