<?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 Amrit Srivastava on Medium]]></title>
        <description><![CDATA[Stories by Amrit Srivastava on Medium]]></description>
        <link>https://medium.com/@srivastava.amrit1999?source=rss-90279b69b340------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*HsHvOkqbRoSfx7bxiXIqhA.jpeg</url>
            <title>Stories by Amrit Srivastava on Medium</title>
            <link>https://medium.com/@srivastava.amrit1999?source=rss-90279b69b340------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 12:30:15 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@srivastava.amrit1999/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[ELI5: Understanding RxJS Observables]]></title>
            <link>https://engineering.wisflux.com/eli5-understanding-rxjs-observables-4f99794dd701?source=rss-90279b69b340------2</link>
            <guid isPermaLink="false">https://medium.com/p/4f99794dd701</guid>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[redux]]></category>
            <category><![CDATA[reactive-programming]]></category>
            <category><![CDATA[rxjs]]></category>
            <dc:creator><![CDATA[Amrit Srivastava]]></dc:creator>
            <pubDate>Thu, 30 May 2019 09:30:06 GMT</pubDate>
            <atom:updated>2026-05-05T10:00:25.318Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*IG4q0xIvLxVsBnrC.png" /><figcaption>Resource: Google Images</figcaption></figure><p>In this post, I’m going to cover the basic concepts of the <a href="https://rxjs.dev/">RxJS</a> with the help of <strong><em>real-world </em></strong><em>analogies</em>. Let’s get the show on the road -</p><h3>What is Reactive programming?</h3><blockquote>Reactive Programming is an asynchronous <strong>programming</strong> paradigm concerned with data streams and the propagation of change.</blockquote><blockquote><strong>ReactiveX</strong> or Rx is the most popular API for <strong>reactive programming</strong>. It’s built on the ideologies of the Observable Pattern, Iterator Pattern, and Functional <strong>Programming.</strong><br>- Wikipedia</blockquote><h3>What is RxJs?</h3><blockquote>RxJS (Reactive Extensions for Javascript) is a library for reactive programming using Observables, to make it easier to compose asynchronous or callback-based code.</blockquote><blockquote>It makes composing asynchronous and event-based programs very easy by using observable streams. It provides one core type, the <strong>Observable</strong>, satellite types (<strong>Observer, Subjects</strong>) and <strong>operators</strong> inspired by Array (like map, filter, reduce, every, etc.) to allow handling asynchronous events as collection streams.</blockquote><h3><strong>Uhh!!</strong> Lots of terms …</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*52GUdu5qc3alyavJ" /></figure><h3>Components of RxJS?</h3><p>To keep things simple, there are only two main components that you need to understand in the beginning, <strong>Observable</strong> and <strong>Observer</strong>. Let’s start with the first one.</p><h3>Observable</h3><p>An observable represents a <strong><em>stream or source of data</em></strong> that can be observed over time for new data events. For example — if you wanted to know mouse coordinates whenever the user clicked somewhere on a page and you had a way to make this event into an observable stream. Now that’s not it, you could do this with regular callbacks but obviously, observables offer so much more which makes RxJS so useful and popular. By the end of this post, you will have a very good idea about what why Observables over simple callbacks pattern.</p><p>You can create an observable from nearly anything, but the most common use case in RxJS is <em>from</em><strong><em> events</em></strong>. This can be anything from mouse moves, button clicks, input into a text field, or even route changes.</p><p><strong>e.g. </strong>Let’s try to understand this with an example of<strong> <em>Water Taps. </em></strong><em>Water </em>is always flowing through pipes to tap but only when a person turns the tap handle, water is then poured into a container. So, let’s say <strong>tap is an observable</strong>, and <strong>water is our data</strong> here; and <strong>turning the tap handle is an act of subscribing</strong>, and you can guess that the container in which water is being poured is our <strong>observer</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/876/1*y9GeqmPWKRbMrPDq7f9FsA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SEF3zx60_-0Ht7nfY9891w.png" /></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e967495e0290a96b92b38b66f91ee3f6/href">https://medium.com/media/e967495e0290a96b92b38b66f91ee3f6/href</a></iframe><h3>Observer</h3><p>An Observer is a <strong><em>consumer of values</em></strong> delivered by an Observable. Observers are simply a <strong><em>set of callbacks</em></strong>, one for each type of notification delivered by the Observable: <strong><em>next, error, and complete</em></strong>. <strong>next </strong>is called whenever a new data value is emitted by an observable. <strong>error </strong>is called when an error has occurred. <strong>complete </strong>is called to let the user know that now there is no more data left to emit.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b024b4c9429ea27dc575a4b90bf8578d/href">https://medium.com/media/b024b4c9429ea27dc575a4b90bf8578d/href</a></iframe><p><strong>e.g. </strong>Now going back to our <strong>Water Tap</strong> example, imagine a water scarce municipality where water from the tap was only available during early morning hours 5–6 am.</p><p>During that period when a person turns the tap handle to fill a bucket with water, we can say that he has now <strong>subscribed</strong> to receive water from the tap. Here tap handle is our control mechanism over the <strong>subscription</strong>. We will talk about subscription in the next topic.</p><p>Now bucket that is being filled is the <strong>next </strong>handler of the observer. The mop is like <strong>error </strong>handler if water gets spilled mop will be used to clean it. Now suppose that water flow is very little and the bucket is not full by 6 am, and supply is stopped at 6 am and there was an alarm to let us know that supply is stopped, that’s like <strong>complete </strong>callback, when that happens person will close the bucket lid close the tap handle and move away.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/786/1*nGAfzrnU_0Heo0rEKKBwuw.png" /></figure><h3>Subscription</h3><p>Subscriptions are what set everything in motion. When subscribing, observer handlers are needed to be supplied.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/312/1*4OaOk0jsvlTgCD5GZJzFIA.jpeg" /></figure><p><strong>e.g. </strong>In our above example, if the user opened the tap at 5:30 am, even though the water was available from 5 am he started getting water upon subscribing by opening the tap. So opening the tap is the act of subscribing. The tap handle is our control over this subscription. In above example, we considered that bucket was not full by 6 am, but if the bucket was full before that user could turn the tap handle to close the tap and not receive any more water, that is the <strong>act of unsubscribing</strong>.</p><p>When we subscribe to an Observable, we get a subscription object in return which can be used to unsubscribe from the observable, to stop receiving any further data events from the observable.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c259360c033d242de53df476bfac26af/href">https://medium.com/media/c259360c033d242de53df476bfac26af/href</a></iframe><h3>Operators</h3><p>Now let’s go beyond basics and talk about the next most important component of RxJS, <strong>Operators</strong>. Operators offer a way to manipulate values from an observable, returning a transformed value for the subscriber or a new observable of transformed values.</p><p><strong>e.g. </strong>Let’s suppose the water our user is getting from the municipality water supply is having some impurities and he wants to purify that water.<strong> </strong>For that, he installed an RO(Reverse Osmosis Purifier) machine before the tap. Now he can get the purified water from the tap of the RO. This is similar to the functionality of operators. RxJS has operators which process the incoming data stream and returns another processed observable or data value.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/948/1*hj1hvgP0NGf4McKRfGnBNg.png" /></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8fff1b499d95ec6f7a6a049da7769504/href">https://medium.com/media/8fff1b499d95ec6f7a6a049da7769504/href</a></iframe><p>In the code above you can see that we user <strong>filter </strong>operator to subscribe only to odd values from the observable which is emitting 1–10 in sequence.</p><h3>So</h3><p>That’s it, I hope it helped. Analogies are probably not perfect but they give you a good sense for formulating a simple mental model of RxJS basic constructs.</p><p><em>Author</em>: <strong>Amrit Srivastava</strong>, is a star software intern at <a href="https://wisflux.com/"><strong>Wisflux</strong></a>,<strong> </strong>currently pursuing his final year of B. Tech. in Computer Science. He likes and knows MERN Stack, he is passionate about learning new technologies. He also likes to tinker and learn with new age machine learning methods and technologies. In free time he likes to sing opera… hehe, in his dreams :)</p><p><strong>References</strong>:</p><ol><li><a href="https://www.learnrxjs.io/">https://www.learnrxjs.io/</a></li><li><a href="https://rxjs.dev/">https://rxjs.dev/</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4f99794dd701" width="1" height="1" alt=""><hr><p><a href="https://engineering.wisflux.com/eli5-understanding-rxjs-observables-4f99794dd701">ELI5: Understanding RxJS Observables</a> was originally published in <a href="https://engineering.wisflux.com/">Wisflux Engineering Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Amrit Srivastava : Comprehensive guide for getting started into competitive/sports programming]]></title>
            <link>https://medium.com/hackslash/comprehensive-guide-for-getting-started-into-competitive-sports-programming-f5ee56beae31?source=rss-90279b69b340------2</link>
            <guid isPermaLink="false">https://medium.com/p/f5ee56beae31</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[competitive-programming]]></category>
            <category><![CDATA[algorithms]]></category>
            <dc:creator><![CDATA[Amrit Srivastava]]></dc:creator>
            <pubDate>Sat, 02 Sep 2017 14:19:38 GMT</pubDate>
            <atom:updated>2017-09-02T16:52:06.974Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*PDIEFG49s5xf5oKC." /><figcaption>(Source : Google Images)</figcaption></figure><p>The thing that fascinates me towards programming is that you just once set some logic and then get the answer just by inputting some values, you need not calculate for each input again and again.</p><blockquote>Programming is an art of making things easier writing just a few lines of code.</blockquote><p>In the present scenario, most of the students think that programming is just making simple programs that we are studying in our syllabus like find prime numbers, factorial, even or odd numbers, etc. You can find resumes full of programming languages, and yet struggling with implementing algorithms.</p><h3><strong>Analysis and Constraints</strong></h3><p>In starting my opinion was also same for programming, but when I came across “competitive programming” for the first time it left me wondering. The questions there are totally different from what we study. Sometimes, there are more than one way to solve a problem. So, there we need to learn how to compare the performance different algorithms and choose the best one to solve a particular problem. While analyzing an algorithm, we mostly consider time complexity and space complexity.</p><ul><li><strong>Time complexity</strong> of an algorithm quantifies the amount of time taken by an algorithm to run as a function of the length of the input.</li></ul><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FMyeV2_tGqvw%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DMyeV2_tGqvw&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FMyeV2_tGqvw%2Fhqdefault.jpg&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/8f118c9c4e25c5e0d15a67873bf7f05d/href">https://medium.com/media/8f118c9c4e25c5e0d15a67873bf7f05d/href</a></iframe><ul><li><strong>Space complexity</strong> of an algorithm quantifies the amount of space or memory taken by an algorithm to run as a function of the length of the input.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/638/0*3FnOIaLpFFMFSXA0." /><figcaption>(Source : <a href="https://www.google.co.in/url?sa=i&amp;rct=j&amp;q=&amp;esrc=s&amp;source=images&amp;cd=&amp;cad=rja&amp;uact=8&amp;ved=0ahUKEwihwI6F7oTWAhXDuI8KHUBHDRUQjRwIBw&amp;url=https%3A%2F%2Fwww.slideshare.net%2Fkumar_vic%2Fanalysis-of-algorithn-class-2&amp;psig=AFQjCNEPiulaTeAVnlS6yTB-kCDBK4CnLQ&amp;ust=1504385281197282">https://www.google.co.in/analysis_of_algorithms</a>)</figcaption></figure><p><strong>Order of growth</strong> is how the time of execution depends on the length of the input. In the above example, we can clearly see that the time of execution is linearly depends on the length of the array. Order of growth will help us to compute the running time with ease.</p><p>But if we go for competitive programming there we have theoretical problems to code, there are questions having situations where we have been given some variables and constraints for each given variable and it’s quite difficult to code these type of problems at first. For example, in a simple program that we make we have just 5 to 10 cases to check that program, but in these problems that we face are</p><ul><li>Improper declaration of datatypes</li><li>Program exceed the time limit</li><li>Doesn’t pass all the test cases.</li></ul><h3>Where to practice ?</h3><p>To overcome these problems and solve these type of problems we should be good at writing algorithms. Now the next question is that from where to learn to solve these type of problems? There are many online sites which may help you out in solving these problems. Some of them are</p><ul><li><a href="https://www.hackerrank.com/">Hackerrank</a></li><li><a href="https://www.hackerearth.com/">Hackerearth</a></li><li><a href="https://www.codechef.com/">Codechef</a></li><li><a href="http://www.geeksforgeeks.org/">Geeks-for-Geeks</a></li><li><a href="http://www.spoj.com/">SPOJ</a></li></ul><p>And many more. There you get hundreds of different problems to practice. And trust me, there’s nothing better than “learning by doing” when it comes to programming!</p><p>So, start practicing to get a good career opportunity and making most out of your 3/4 years.</p><blockquote><strong>“Programming is like mathematics, the more you practice the more you get”</strong></blockquote><p><em>References :-</em></p><ol><li>Google.com</li><li>Hackerrank.com</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f5ee56beae31" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hackslash/comprehensive-guide-for-getting-started-into-competitive-sports-programming-f5ee56beae31">Amrit Srivastava : Comprehensive guide for getting started into competitive/sports programming</a> was originally published in <a href="https://medium.com/hackslash">HackSlash</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>