<?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 Neel Bommisetty on Medium]]></title>
        <description><![CDATA[Stories by Neel Bommisetty on Medium]]></description>
        <link>https://medium.com/@neelbommisetty?source=rss-3f60613c713a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*IKr3xdJNVIDQ2q2l8m_vqA.jpeg</url>
            <title>Stories by Neel Bommisetty on Medium</title>
            <link>https://medium.com/@neelbommisetty?source=rss-3f60613c713a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 16:07:06 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@neelbommisetty/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[Creating Observables — RxJS Creation Operators]]></title>
            <link>https://medium.com/@neelbommisetty/creation-observables-rxjs-creation-operators-f9d1f827c60c?source=rss-3f60613c713a------2</link>
            <guid isPermaLink="false">https://medium.com/p/f9d1f827c60c</guid>
            <category><![CDATA[operators]]></category>
            <category><![CDATA[reactive-programming]]></category>
            <category><![CDATA[observables]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[rxjs]]></category>
            <dc:creator><![CDATA[Neel Bommisetty]]></dc:creator>
            <pubDate>Mon, 02 Oct 2017 11:47:14 GMT</pubDate>
            <atom:updated>2017-10-02T11:57:05.315Z</atom:updated>
            <cc:license>http://creativecommons.org/publicdomain/zero/1.0/</cc:license>
            <content:encoded><![CDATA[<p>In the previous articles we tried to understand what an observable is and how it works and how it behaves in case of different scenarios. We looked at how to handle errors in observables and also learnt that observables end.</p><p>Here in this article we go in depth about how to create an observable.</p><p>RxJs has quite a few methods to create an observable and we will be going through a few of them in this article.</p><h3>Create</h3><p>Lets start with the create Operator, the one we used in the previous articles to create an Observable.</p><p>As Stated in documentation “ Rx.Observable.create is an alias for the Observable constructor” is the best way to describe it.</p><p>The syntax of this method is pretty straight forward , it takes a single function as input , which in turn is passed the observer which can emit values with .next(), throw errors with .error() and complete with .complete() .</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0caf28ea3c62f378ec8d39c7b4211238/href">https://medium.com/media/0caf28ea3c62f378ec8d39c7b4211238/href</a></iframe><p>Often It is difficult to use create method to create a complex observable. So we have many more so called creation operators which makes using observables very simple and easy.</p><h3>Of</h3><p>First comes Of operator, probably the simplest creation operator of all.</p><p>This operator creates an Observable that emits the values you specify as arguments, immediately one after the other, and then emits a complete notification.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h3oLHbPaTmJ5xXKGiVo4sw.png" /></figure><p>Using it is also very simple.Check out the example below.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/689040dfcb9e6299d99788ac6ca28cc5/href">https://medium.com/media/689040dfcb9e6299d99788ac6ca28cc5/href</a></iframe><h3>FromEventPattern</h3><p>Next comes FromEventPattern that creates an Observable from an API based on addHandler/removeHandler functions.</p><p>The FromEventPattern method takes two arguments one is addHandler and the other is removeHandler.The addHandler is called when the output Observable is subscribed, and removeHandler is called when the Subscription is unsubscribed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GdtqFiTyu4N-gwSV6wL9Mg.png" /></figure><p>The Syntax of this method is as follows</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/979627a179fa80e7df246a6addab84f2/href">https://medium.com/media/979627a179fa80e7df246a6addab84f2/href</a></iframe><h3>FromEvent</h3><p>FromEvent method creates an Observable that emits events of a specific type coming from the given event target.</p><p>For example you can use this method to create an Observable from DOM events, or Node EventEmitter events or others.</p><p>You can say it is syntactic sugar for the FromEventPattern to handle the cases of Dom Events and Node EventEmitter .</p><p>This method takes two arguments one is the target (like a dom element) and an eventName .The event handler is attached when the output Observable is subscribed, and removed when the Subscription is unsubscribed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5MDnk5nMS_z1lT96gyZqqA.png" /></figure><p>Syntax of the FromEvent is as follows</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/72143c6d24a9bb6ae9fc4dd964463d2a/href">https://medium.com/media/72143c6d24a9bb6ae9fc4dd964463d2a/href</a></iframe><h3>FromPromise</h3><p>FromPromise method simply converts a promise in to an Observable.It returns an Observable that just emits the Promise’s resolved value, then completes.</p><p>This methods takes a promise as an input.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/368af0529c136a9ba1a9bbdbd29552ac/href">https://medium.com/media/368af0529c136a9ba1a9bbdbd29552ac/href</a></iframe><h3>Interval</h3><p>Interval creates an Observable that emits sequential numbers every specified interval of time.It starts with 0 and it never ends.</p><p>This method takes Time Interval at which the number are to be emitted in ms.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HWj0O_gmMus1DfBL_XD68w.png" /></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e4fca79dbdda96a53f351d34b86af3c6/href">https://medium.com/media/e4fca79dbdda96a53f351d34b86af3c6/href</a></iframe><h3>Range</h3><p>Range creates an Observable that emits a sequence of numbers within a specified range.Range operator emits a range of sequential integers, in order, where you select the start of the range and its length.</p><p>This methods takes 2 arguments one is the start and the other is length of the sequence.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4m0D6MgWL8zuNWGucN0U4g.png" /></figure><p>Syntax of range observable goes something like this.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2d34d0f48013edd0d1a9d3383a1c793e/href">https://medium.com/media/2d34d0f48013edd0d1a9d3383a1c793e/href</a></iframe><h3>Timer</h3><p>Timer creates an Observable that starts emitting after an initialDelay and emits ever increasing numbers after each period of time thereafter.</p><p>If the second argument is not passed it just emits 0 after the initial delay and completes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*06PrYMUut_1WD71HJH-bwg.png" /></figure><p>The Syntax os Timer goes as follows.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/63239ab4ca503454aad43dcfd95ba2c6/href">https://medium.com/media/63239ab4ca503454aad43dcfd95ba2c6/href</a></iframe><p>There are few Utility creation operators that are used in conjunction with other operators to handle certain cases. Some of them are listed below.</p><h3>Empty</h3><p>empty operator works exactly as its name suggests.It emits no values and immediately emits a complete notification.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tCLlghDYt5XcrFZB68ubAQ.png" /></figure><p>You can use it as shown below</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/248caa1c4add9888823f81f3c1676fcc/href">https://medium.com/media/248caa1c4add9888823f81f3c1676fcc/href</a></iframe><h3>Throw</h3><p>Similarly Throw method is used to throw an error and do nothing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KahZaPz7fuweIwPERlKQ8g.png" /></figure><p>Its syntax is similar to empty.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0eedc2102e89dac4415e90eee5551199/href">https://medium.com/media/0eedc2102e89dac4415e90eee5551199/href</a></iframe><h3>Never</h3><p>Similarly Never method does nothing actually it never emits any value, nor throws error nor completes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hDjxQuz6_licxFVy3psGjg.png" /></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/88b67033bde56956d4b29e210d1547d4/href">https://medium.com/media/88b67033bde56956d4b29e210d1547d4/href</a></iframe><p>These are some of the operators to create observables.However there are even more methods to make those. These methods are probably enough to handle most of the cases you may probably encounter.</p><p>The Images are from Official RxJs Docs. You can check them <a href="http://reactivex.io/rxjs/manual/overview.html#introduction">here.</a></p><p>I Will be writing more about Operators in my next blog. Operators are what makes RxJs. So Powerful and easy to use. Here we Already saw some creation operators.But there are many more operator to handle our daily use cases effectively.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f9d1f827c60c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introduction to RxJS and Observables — Part II]]></title>
            <link>https://medium.com/@neelbommisetty/introduction-to-rxjs-and-observables-part-ii-db2215ec3959?source=rss-3f60613c713a------2</link>
            <guid isPermaLink="false">https://medium.com/p/db2215ec3959</guid>
            <category><![CDATA[reactive-programming]]></category>
            <category><![CDATA[rxjs]]></category>
            <category><![CDATA[observables]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[xr]]></category>
            <dc:creator><![CDATA[Neel Bommisetty]]></dc:creator>
            <pubDate>Thu, 21 Sep 2017 14:13:06 GMT</pubDate>
            <atom:updated>2017-09-21T14:13:06.111Z</atom:updated>
            <cc:license>http://creativecommons.org/publicdomain/zero/1.0/</cc:license>
            <content:encoded><![CDATA[<p>This is a 2nd article of a two part series on introduction to observables. In case you missed the first one you can read it <a href="https://medium.com/@neelbommisetty/introduction-to-rxjs-and-observables-part-i-8863fa6c7b42">here</a>.</p><p>In the last article we studied about how we could send multiple values over an observable using next function.</p><p>How ever we also know that we can use a generators to return multiple values.</p><p>So Lets see how observables are different from generators .</p><p>We can create a generator using the * after the function and it returns an iterator . We can use iterator.next() to</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f87021f1681812072df2d2ffc95e8229/href">https://medium.com/media/f87021f1681812072df2d2ffc95e8229/href</a></iframe><p>In case of generator we observe that we pull the values from source when required.</p><p>We know how we return multiple values using observables.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a67430d4717d668ab282b85b41cbd280/href">https://medium.com/media/a67430d4717d668ab282b85b41cbd280/href</a></iframe><p>Here is we see that the source pushes the values and the subscriber reacts to those values.</p><p>This is a key difference between observable and generator.</p><p>Now let’s talk about errors. Errors Happen every now and then we know that we can throw error with error keyword and we have a way to handle errors with try catch block.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c00a85d2ef6c76f18a5016ea5725eb3d/href">https://medium.com/media/c00a85d2ef6c76f18a5016ea5725eb3d/href</a></iframe><p>We can throw an error in observable using .error on the observer ,the API here is similar to observer.next; essentially, instead of delivering a value, we are delivering an error. And then to catch those errors, we need to modify the code in our .subscribe for the consumers that subscribe.</p><p>In the subscribe function you can actually pass in a second function as parameter which acts as the error handler.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2cb54e7430c0d5abc4675dc012ac2472/href">https://medium.com/media/2cb54e7430c0d5abc4675dc012ac2472/href</a></iframe><p>Here you see that second handler actually handles the errors. and generally wrapping the function passed to create api in try/catch block and throwing error in the catch block is generally a good idea.</p><p>So far, we’ve seen that observers are the consumers of values that observable produces. Observers seem to have at least two functions attached to them. They have .next to get values. They have .error to get an exception. What else does this Observer object include? It also has .complete, which takes no value or error. It has zero arguments.</p><p>Observer.complete allows a producer, this observable, to tell its consumers that it has finished. It won&#39;t deliver any values anymore. In the .subscribe here, we can add a third handler, the completeHandler(), which also takes no arguments. Here, we can detect when the observable ended.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0caf28ea3c62f378ec8d39c7b4211238/href">https://medium.com/media/0caf28ea3c62f378ec8d39c7b4211238/href</a></iframe><p>Notice two things here the completion handler handled the complete event and also you can see that 400 is not logged. That is because after an observable is completed values passed to next function are just ignored and not received by subscriber.</p><p>Completion is an important concept, as we will see later on. Imagine if you want to concatenate two observables. You can only do that if the first one ends. Then you know that the second observable takes over after that.</p><p>Completion is also important in other ways. For instance, let’s say that observer is only interested in the last value that observableproduced. This last can only be determined if there is a way to know that the observable has finished and won&#39;t deliver any values anymore.</p><p>In conclusion, that’s all an Observable can do. It can deliver values, pushing them to observers. It can deliver errors. It can deliver a completion notification.</p><p>In the next article I would writing about creation of observables. There are lot more creation operators other than create which we used in this and the previous article.</p><p>As mentioned in the previous article this article series is a summary of what i learnt from <a href="https://medium.com/u/3ba9db42812d">André Staltz</a> in his egghead.io courses.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=db2215ec3959" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introduction to RxJS and Observables — Part I]]></title>
            <link>https://medium.com/@neelbommisetty/introduction-to-rxjs-and-observables-part-i-8863fa6c7b42?source=rss-3f60613c713a------2</link>
            <guid isPermaLink="false">https://medium.com/p/8863fa6c7b42</guid>
            <category><![CDATA[reactive-programming]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[observables]]></category>
            <category><![CDATA[rxjs]]></category>
            <category><![CDATA[xr]]></category>
            <dc:creator><![CDATA[Neel Bommisetty]]></dc:creator>
            <pubDate>Mon, 18 Sep 2017 15:00:41 GMT</pubDate>
            <atom:updated>2017-09-18T15:01:12.876Z</atom:updated>
            <cc:license>http://creativecommons.org/publicdomain/zero/1.0/</cc:license>
            <content:encoded><![CDATA[<p>Observable is by far the most important concept in this library. I would call it a powerful generalization of a function. I can explain what I mean.</p><p>Lets start by learning about functions.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2382ab4fbb317189ca8e1819df91979d/href">https://medium.com/media/2382ab4fbb317189ca8e1819df91979d/href</a></iframe><p>If you care fully observe the above code snippet you understand that the declaration of function is Lazy. By lazy i mean the code inside the function is not executed until the function is called.</p><p>Now let’s make an Observable and compare it with a function.</p><p>We can create an Observable using Rx.Observable.create Create operator helps you create the Observable.</p><p>Now, observables have a method called subscribe. That takes a function which takes the value x. x is whatever was fed through .next. Once I have that value x, I can just put it in console.log, almost the same thing we had for functions.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/32fe8cad5c2a2c241a09696db00d553a/href">https://medium.com/media/32fe8cad5c2a2c241a09696db00d553a/href</a></iframe><p>What happens then if I comment out our .subscribe block? Basically, I don&#39;t have a .subscribe anymore. What will happen? Well, nothing. That means that whatever is inside an observable is also a lazy computation. Just like with functions, if you don&#39;t express your interest in the values, then nothing will happen.</p><p>So far, no difference at all.Then what is really the difference between observables and functions?</p><p>Here is one major thing, is that you can call observer.next multiple times. You can give another value, so here is .next(100). Here is .next(200), and now we&#39;re basically returning many values. Where as functions end after a value is returned.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a67430d4717d668ab282b85b41cbd280/href">https://medium.com/media/a67430d4717d668ab282b85b41cbd280/href</a></iframe><p>Also Observables can also be asynchronous.Here I want you to understand that while Observables can be asynchronous, they can be synchronous as well. Let me give you an example to understand better.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/643567bb0852e8c0abe18f0e9243a83d/href">https://medium.com/media/643567bb0852e8c0abe18f0e9243a83d/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/179ef02dddcb70c08f584574100fa57d/href">https://medium.com/media/179ef02dddcb70c08f584574100fa57d/href</a></iframe><p>This is a part 1 of 2 Articles about Introduction to observables and RxJs.I will continue with more on creation of observables and followed operators which makes observables so powerful and easy to use.</p><p>This article series is a summary of what i learnt from <a href="https://medium.com/u/3ba9db42812d">André Staltz</a> course on E<a href="https://egghead.io/">gghead</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8863fa6c7b42" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>