<?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 Mohit Chauhan on Medium]]></title>
        <description><![CDATA[Stories by Mohit Chauhan on Medium]]></description>
        <link>https://medium.com/@mohit.chauhan.mi?source=rss-b297ed2ba15------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*GzhNM1Un-8x4P8RAcoNymQ.jpeg</url>
            <title>Stories by Mohit Chauhan on Medium</title>
            <link>https://medium.com/@mohit.chauhan.mi?source=rss-b297ed2ba15------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 05:02:14 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mohit.chauhan.mi/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[Reactive Programming Using RxDart For Flutter Applications - Part 1]]></title>
            <link>https://medium.com/mindful-engineering/reactive-programming-using-rxdart-for-flutter-applications-part-1-a0b70e99a6e2?source=rss-b297ed2ba15------2</link>
            <guid isPermaLink="false">https://medium.com/p/a0b70e99a6e2</guid>
            <category><![CDATA[reactive-programming]]></category>
            <category><![CDATA[rxdart]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[reactivex]]></category>
            <dc:creator><![CDATA[Mohit Chauhan]]></dc:creator>
            <pubDate>Sun, 08 Aug 2021 18:33:06 GMT</pubDate>
            <atom:updated>2021-08-09T04:25:29.230Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Reactive programming is programming with asynchronous observable streams. In Dart, stream provide an asynchronous sequence of data. In this </em><strong><em>first part</em></strong><em>, we will be looking on how to do reactive programming for our flutter applications by extending the capabilities of dart stream with RxDart using it’s </em><strong><em>Subjects</em></strong><em> and </em><strong><em>Stream Classes</em></strong><em>. In</em><strong><em> next part</em></strong><em> we will check the </em><strong><em>Extension Methods</em></strong><em> on the Stream Classes aka Operators of Rx.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*8141SJRj26NQQCxn" /><figcaption>tPhoto by <a href="https://unsplash.com/@jordanmcdonald?utm_source=medium&amp;utm_medium=referral">Jordan</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Introduction</h3><p>Dart streams were developed with reactive programming in mind, Instead of providing an alternative to it, <strong>RxDart</strong> adds additional functionality using the reactive approach on top of it.</p><h4>Setup</h4><p>Add rxdart to your flutter project’s <strong>pubspec.yaml</strong> file:</p><pre>dependencies:<br>  <strong>rxdart</strong>:</pre><p>Now in our code, we can use it by importing it:</p><pre><strong>import</strong> &#39;package:rxdart/rxdart.dart&#39;;</pre><p><strong>RxDart</strong> does not provide <strong>Rx’s</strong> main class <em>Observable</em> as alternative for Dart Streams. Instead, it offers several additional <strong>Subjects, Stream Classes and Extension Methods on the Stream Classes (</strong>Operators of Rx<strong>). </strong>let’s look over it,</p><h3><strong>Subjects</strong></h3><p>In Dart, if we’ve to send data, error and done events to its stream we use <em>StreamController </em>but<em>, </em>in <strong><em>RxDart</em></strong> we have to use <em>Subject</em> which is the same as <em>StreamController</em> but with additional stuff.</p><p>all the <em>subjects</em> of <em>RxDart</em> is similar to <em>broadcast StreamController </em>which<em> </em>means we can listened to the subject’s stream as many time as we want.</p><h4>BehaviorSubject</h4><p>In<em> BehaviorSubject </em>the most recent item that we added to our subject is dispatched to it’s new listeners. When we listen to our new listener it will <strong>receive the</strong> <strong>latest</strong> <strong>stored</strong> <strong>item</strong> from the subject and after that new event will be sent to all other listeners. let’s see with example,</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6718c6e7e7058c5466180cd7cedcc0fa/href">https://medium.com/media/6718c6e7e7058c5466180cd7cedcc0fa/href</a></iframe><p>We can also assign an <strong>initial</strong> <strong>value</strong> to our <em>BehaviorSubject</em>. like this,</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/acf30c2ff763c6c97d563e41790f2ffd/href">https://medium.com/media/acf30c2ff763c6c97d563e41790f2ffd/href</a></iframe><h4>PublishSubject</h4><p>In <em>PublishSubject </em>all the items that we added to our subject is dispatched to it’s listeners. this is most easiest subject among other subjects provided by rxdart.<br>for this, the <strong>sequence</strong> <strong>of listener matters</strong> for adding and listening to the items of <em>PublishSubject</em>. let’s see with example,</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1df32fee1db365a8b9c4784170026dd3/href">https://medium.com/media/1df32fee1db365a8b9c4784170026dd3/href</a></iframe><h4>ReplaySubject</h4><p>In <em>ReplaySubject</em> all the items we added to our subject is dispatched to it’s listeners <strong>doesn’t matter the sequence</strong> when we add first or listen first to that items of <em>ReplaySubject, </em>unlike <em>PublishSubject and BehaviorSubject</em>. let’s see with example,</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d3d9a95f67d606d37f56ef134b846842/href">https://medium.com/media/d3d9a95f67d606d37f56ef134b846842/href</a></iframe><p>We can also specify a <strong><em>maxSize</em></strong> value at the time of initializing the <em>ReplaySubject</em> variable. this means we can only listen to the number of latest items that equal to the <em>maxSize</em>. like this,</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d448eafe1444a6f01c1c225eb7a0f522/href">https://medium.com/media/d448eafe1444a6f01c1c225eb7a0f522/href</a></iframe><blockquote><strong>But maxSize did not work when we added items later / or after the listener.</strong></blockquote><h3>Stream Classes</h3><p>The <em>Stream Class </em>is a source of asynchronous data events. <strong>RxDart</strong> gives us different ways to create a <em>Stream</em> with <em>Stream Classes</em> that have additional capabilities to create a variety of tasks as per our requirement, such as combining or merging Streams!!</p><p>We can create the <em>Streams</em> provided by RxDart in <strong>two</strong> ways. by instantiating the stream class directly like this,</p><pre>final mergedStream = MergeStream([firstStream, secondStream]);</pre><p>and using static factories from the <strong>Rx</strong> class like this,</p><pre>final mergedStream = Rx.merge([firstStream, secondStream]);</pre><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2F3oKIPlLZEbEbacWqOc%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2Freactionseditor-interesting-hmm-3oKIPlLZEbEbacWqOc&amp;image=https%3A%2F%2Fmedia3.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExenF3dHF3bmI4NTcyaGhjdmpqMTA0ajF0MzZkZWY1anY3dzEyY2MyMCZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw%2F3oKIPlLZEbEbacWqOc%2Fgiphy_s.gif&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="326" frameborder="0" scrolling="no"><a href="https://medium.com/media/d20834cfb858ea862ea824112a5cbec9/href">https://medium.com/media/d20834cfb858ea862ea824112a5cbec9/href</a></iframe><p>There are so many <strong><em>Stream Classes</em></strong> are provided by <strong><em>RxDart</em></strong> let’s see them with example,</p><ul><li><strong>CombineLatestStream : </strong>This stream joins all the given streams into one single stream sequence by combining them when any of the source stream sequences send forth an item. this stream will emit items after all others streams that we want to combine have emitted at least one item. If any of the streams that we want to combine is empty then the resulting sequence completes instantly without emitting any items.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4c7a5d85993734ef48ae49b20c284365/href">https://medium.com/media/4c7a5d85993734ef48ae49b20c284365/href</a></iframe><ul><li><strong>ConcatStream : </strong>This stream is used when we want to concatenates all stream sequences. <em>ConcatStream</em><strong> </strong>concat the next stream sequence after the previous stream sequence is terminated successfully. In case where the streams is empty then it’s completes instantly without emitting any items.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/10a2f1ea28b8e49017f3f5b50cee155b/href">https://medium.com/media/10a2f1ea28b8e49017f3f5b50cee155b/href</a></iframe><ul><li><strong>ConcatEagerStream : </strong>This stream is similar with <em>ConcatStream only the </em>difference is that instead of subscribing to stream one by one, all the streams are immediately subscribed with correct time.</li><li><strong>DeferStream : </strong>This stream is used when we want to constructs a stream lazily when we subscribes to it. In some case we have to wait until the last minute to generate the stream that have latest data. it’s a single subscription stream but we can make it reusable.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7231ec7241840bdcf6155f755430636f/href">https://medium.com/media/7231ec7241840bdcf6155f755430636f/href</a></iframe><ul><li><strong>ForkJoinStream : </strong>This stream is used when we only want sequence that contains only final emitted value of each stream. in the case where any of the inner streams have some error then we will lose the value of any other streams that already completed if we not catch that error correctly on the inner stream.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e0be661e94e3b3825ea72a091cf0de15/href">https://medium.com/media/e0be661e94e3b3825ea72a091cf0de15/href</a></iframe><ul><li><strong>FromCallableStream : </strong>This stream is used when we want to return a stream that is based on the result of some function. the stream emits the value that’s returned from that function.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/203f170cd50d6c80f098f727f8338366/href">https://medium.com/media/203f170cd50d6c80f098f727f8338366/href</a></iframe><ul><li><strong>MergeStream : </strong>This stream is used when we have to flattens the items that emitted by the given streams into a single sequence of stream. In this the items is emitted one after another from all the given streams.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/14aaa745878fb7be3219d607118972e1/href">https://medium.com/media/14aaa745878fb7be3219d607118972e1/href</a></iframe><ul><li><strong>NeverStream : </strong>This stream returns a non-terminating stream sequence, which can be used for infinite duration. this stream have very specific and limited behavior. as per my knowledge this is used for testing purposes only.</li><li><strong>RaceStream : </strong>This stream returns a stream that emits all of it’s items before any other streams emits it’s items.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d963d3f076cd84d180708938ad14e1a3/href">https://medium.com/media/d963d3f076cd84d180708938ad14e1a3/href</a></iframe><ul><li><strong>RangeStream : </strong>This stream class basically used when we want to returns a resulting stream that emits a sequence of integers within a particular range that we added.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8b65d8dbf2e4bd8f678da441e8155eaa/href">https://medium.com/media/8b65d8dbf2e4bd8f678da441e8155eaa/href</a></iframe><ul><li><strong>RepeatStream : </strong>This stream creates a stream that will recreate it self and re- listen to the source stream for the specified number of times until the stream terminates successfully. In case if we forget to specify the count then it repeats indefinitely.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3de1a4098c08280b52f20bc605cebab0/href">https://medium.com/media/3de1a4098c08280b52f20bc605cebab0/href</a></iframe><ul><li><strong>RetryStream : </strong>This stream is similar with <em>RepeatStream only the </em>difference is that if the retry count is not specified, it retries indefinitely and if the retry count is met, but the stream has not terminated successfully then all of the errors that caused the failure will be emitted at the end.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/aa0877660567ffb51c2c548a5efb7f0a/href">https://medium.com/media/aa0877660567ffb51c2c548a5efb7f0a/href</a></iframe><ul><li><strong>RetryWhenStream : </strong>This stream is somehow similar with the <em>RetryStream the difference is it will take two stream as an </em>argument (streamFactory and retryWhenFactory). if the retryWhenFactory throws an error or returns a stream that emits an error then the original error will be emitted and then the error from retryWhenFactory will be emitted if it is not same as the original error.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fec4cbb9ff056c258e8c349e916b064c/href">https://medium.com/media/fec4cbb9ff056c258e8c349e916b064c/href</a></iframe><ul><li><strong>SequenceEqualStream : </strong>This stream is used to check that whether the two streams emit the same sequence of items or not.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/08cc5b0b37ce705313a9b68ba3c56914/href">https://medium.com/media/08cc5b0b37ce705313a9b68ba3c56914/href</a></iframe><ul><li><strong>SwitchLatestStream : </strong>This stream is used when we only want the single streams items that emitted most recently from the multiple streams.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9e4d56149aa6341a7eefc24c4b78405f/href">https://medium.com/media/9e4d56149aa6341a7eefc24c4b78405f/href</a></iframe><ul><li><strong>TimerStream : </strong>This stream is useful when we want to emits an item after a some specific amount of time.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e6f76cd0dbf0685fb2231ca5a22d77d2/href">https://medium.com/media/e6f76cd0dbf0685fb2231ca5a22d77d2/href</a></iframe><ul><li><strong>UsingStream : </strong>This stream<strong> </strong>is used to create a way so we can instruct an stream to create a resource for us that exists only during the lifetime of the stream and is disposed when the stream terminates.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/79b344f5e65bcb7a49cf2fefcf9acde2/href">https://medium.com/media/79b344f5e65bcb7a49cf2fefcf9acde2/href</a></iframe><ul><li><strong>ZipStream : </strong>This stream is used to merge all the specified streams into a one single stream sequence using the zipper function whenever all of the stream sequences have produced an element at a corresponding index.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/eedc0eccb6d1e42ac490111f8b3a6108/href">https://medium.com/media/eedc0eccb6d1e42ac490111f8b3a6108/href</a></iframe><p><strong><em>Well done!</em></strong><em> You’ve survived Part 1 of Reactive Programming Using RxDart in which we check </em><strong><em>RxDart’s Subjects and Stream Classes.</em></strong></p><blockquote><em>All </em>explanation and example <em>code in this part is based on rxdart version 0.27.1.</em></blockquote><p><em>Now you’re </em><strong><em>ready</em></strong><em> to check </em><a href="https://medium.com/mindful-engineering/reactive-programming-using-rxdart-for-flutter-applications-part-2-9bfc8a7ac5b5?source=post_settings_page-----9bfc8a7ac5b5----0----------------------------"><em>Part 2 of Reactive Programming Using RxDart</em></a><em>. In that we will check the </em><strong><em>Extension Methods on the Stream C</em>lasses<em> aka Operators of Rx.</em></strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a0b70e99a6e2" width="1" height="1" alt=""><hr><p><a href="https://medium.com/mindful-engineering/reactive-programming-using-rxdart-for-flutter-applications-part-1-a0b70e99a6e2">Reactive Programming Using RxDart For Flutter Applications - Part 1</a> was originally published in <a href="https://medium.com/mindful-engineering">Mindful Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Reactive Programming Using RxDart For Flutter Applications — Part 2]]></title>
            <link>https://medium.com/mindful-engineering/reactive-programming-using-rxdart-for-flutter-applications-part-2-9bfc8a7ac5b5?source=rss-b297ed2ba15------2</link>
            <guid isPermaLink="false">https://medium.com/p/9bfc8a7ac5b5</guid>
            <category><![CDATA[reactive-programming]]></category>
            <category><![CDATA[reactivex]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[rxdart]]></category>
            <dc:creator><![CDATA[Mohit Chauhan]]></dc:creator>
            <pubDate>Sun, 08 Aug 2021 18:33:06 GMT</pubDate>
            <atom:updated>2021-08-09T04:27:34.440Z</atom:updated>
            <content:encoded><![CDATA[<h3>Reactive Programming Using RxDart For Flutter Applications — Part 2</h3><p><em>In </em><a href="https://medium.com/mindful-engineering/reactive-programming-using-rxdart-for-flutter-applications-part-1-a0b70e99a6e2"><strong>previous <em>p</em>art</strong></a><strong> </strong>of this<strong> </strong><em>, we checked rxdart’s </em><strong>Subjects</strong> and <strong>Stream Classes</strong><em>. So now in this </em><strong><em>part</em></strong><em> we will check the </em><strong>Extension Methods</strong> on the <em>Stream Classes</em> which is also known as the <strong>Operators of Rx.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*JnyUZiQtDKPZXnRO" /><figcaption>Photo by <a href="https://unsplash.com/@jordanmcdonald?utm_source=medium&amp;utm_medium=referral">Jordan</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Extension Methods on the Stream Classes (Operators of Rx)</h3><p><em>Extension Methods is used to perform new functionality to an existing stream</em> <em>class.</em></p><blockquote>extension methods is used with any stream class.</blockquote><p>The extension methods of <em>stream classes</em> provided by <em>RxDart</em> is come with many powers. this <em>stream classes</em> is used to transform a source stream into a new stream with <em>unique</em> capabilities, such as throttling or buffering events. let’s see them with example,</p><h4>BufferExtensions</h4><p>To extends the <em>stream class</em> with the facility to buffer or store<strong> </strong>events temporarily in various ways then we can use this extension methods.</p><p><strong>buffer()</strong> to create a stream where all item is a <em>List</em> containing the items from the source sequence.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/66ba5d90270f6204867a85cd1178cdc8/href">https://medium.com/media/66ba5d90270f6204867a85cd1178cdc8/href</a></iframe><p><strong>bufferCount() </strong>to create a buffers of values from the source stream by using count to group them in the buffer and after that clears it and starts a new buffer for each values.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/06c965f6450133ea519d43531872f381/href">https://medium.com/media/06c965f6450133ea519d43531872f381/href</a></iframe><p><strong>bufferTest() </strong>to creates a stream where all item is a <em>List </em>that contains the items from the source sequence and batched when item passes the test.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4373da7a32a5d9501609a6f636d6a9b8/href">https://medium.com/media/4373da7a32a5d9501609a6f636d6a9b8/href</a></iframe><p><strong>bufferTime() </strong>to create a stream where all item is a <em>List</em> that contains the items from the source sequence that stored in buffer based on time frame.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/caebba97309cd76f1b8cf1e581f8a910/href">https://medium.com/media/caebba97309cd76f1b8cf1e581f8a910/href</a></iframe><h4>ConcatExtension</h4><p>To extends the <em>stream class </em>with the facility to concatenate one stream with the another stream.</p><p><strong>concatWith() </strong>this method returns a stream that emits all the items from the current stream after that emits all items from the given streams one at a time.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a114af952560da28cac6e05157c259a1/href">https://medium.com/media/a114af952560da28cac6e05157c259a1/href</a></iframe><h4>DebounceExtensions</h4><p>To extends the <em>stream class</em> with the facility to debounce events in different ways.</p><p><strong>debounce() </strong>to convert a stream in a such a way that will only emit items from the source sequence if a <em>window </em>has completed without the source sequence emitting another item. This <em>window</em> is created after the last debounced event was emitted.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/54516f31ca5a0f3fa2486e7fec407b52/href">https://medium.com/media/54516f31ca5a0f3fa2486e7fec407b52/href</a></iframe><p><strong>debounceTime() </strong>this method is similar with <em>debounce</em>() difference is that when the time span that we defined for duration is passed, without the source sequence emitting another item then only items is emitted.</p><h4>DefaultIfEmptyExtension</h4><p><strong>defaultIfEmpty() </strong>this method emits an items from the source stream or a single default item if the source stream found to be null.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/dbc4191db283c706c39f4a691523c72f/href">https://medium.com/media/dbc4191db283c706c39f4a691523c72f/href</a></iframe><h4>DelayExtension</h4><p>To extends the <em>stream class</em> with the facility to delay events being emitted.</p><p><strong>delay() </strong>to modify a source stream by waiting for some amount of time that we added before emitting each of the source streams items.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9a83e1e840aad73819ce58c72b38ca67/href">https://medium.com/media/9a83e1e840aad73819ce58c72b38ca67/href</a></iframe><h4>DistinctUniqueExtension</h4><p>To extends the <em>stream class</em> with the facility to emit only unique events.</p><p><strong>distinctUnique() </strong>to create a stream where data events are <em>skipped</em> if they have already been emitted before.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2e3546e1fb4e3f7e2e4467c35eab877a/href">https://medium.com/media/2e3546e1fb4e3f7e2e4467c35eab877a/href</a></iframe><blockquote>More commonly known as distinct in other Rx implementations.</blockquote><h4>DoExtensions</h4><p>To extends the <em>stream class</em> with the facility to execute interesting <strong><em>callback functions</em></strong> at different points in the streams lifecycle methods.</p><p><strong>doOnCancel() </strong>executes the <em>callback function</em> when the stream subscription is cancelled.</p><p><strong>doOnData() </strong>executes the <em>callback function</em> when the stream emits an item.</p><p><strong>doOnDone() </strong>executes the <em>callback function</em> when the stream finishes emitting items.</p><p><strong>doOnEach() </strong>executes the <em>callback function</em> when the stream emits data, emits an error, or emits done event of <em>NotificationObject.</em></p><p><strong>doOnError() </strong>executes the <em>callback function</em> when the stream emits an error.</p><p><strong>doOnListen() </strong>executes the <em>callback function</em> when the stream is first listened.</p><p><strong>doOnPause() </strong>executes the <em>callback function</em> when the stream subscription is paused.</p><p><strong>doOnResume() </strong>executes the <em>callback function</em> when the stream subscription resumes receiving items.</p><h4>EndWithExtension</h4><p><strong>endWith() </strong>to<strong> </strong>attach a value as the final item to the source stream before closing it.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/618dfa90cd9eb73da5a9da6e36aa9e18/href">https://medium.com/media/618dfa90cd9eb73da5a9da6e36aa9e18/href</a></iframe><h4>EndWithManyExtension</h4><p><strong>endWithMany() </strong>to attach a sequence of values as final events to the source stream before closing it.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b2e363346855d41d1923438b5d54af1d/href">https://medium.com/media/b2e363346855d41d1923438b5d54af1d/href</a></iframe><h4>ExhaustMapExtension</h4><p><strong>exhaustMap() </strong>to converts the items from the source stream into a new stream using the <em>mapper function</em>. If an item is being processed then it will ignores other items emitted by the source until the current item completed successfully</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c463a21648e67b7e2178887351c7ad63/href">https://medium.com/media/c463a21648e67b7e2178887351c7ad63/href</a></iframe><h4>FlatMapExtensions</h4><p>To extends the <em>stream class</em> with the facility to convert the source stream into a new stream each time when the source stream emits an item.</p><p><strong>flatMap() </strong>to converts all the emitted item into a stream using the <em>mapper function</em>. In this the newly created stream will be be listened to and begin emitting items into it’s downstream by maintaining the same order.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1180b29c994af8e856a670fcbe3d1ae2/href">https://medium.com/media/1180b29c994af8e856a670fcbe3d1ae2/href</a></iframe><p><strong>flatMapIterable() </strong>to converts all the item into a stream. for this stream must return an <em>Iterable </em>after that each item from the <em>Iterable</em> will be emitted one by one.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7474e2f8561e50324c58e9db6be5f90e/href">https://medium.com/media/7474e2f8561e50324c58e9db6be5f90e/href</a></iframe><h4>GroupByExtension</h4><p>To extends the <em>stream class</em> with the facility to convert events into streams of events that are united by a key.</p><p><strong>groupBy() </strong>to divides a stream that emits items into a stream that emits a <em>GroupByStream, </em>each one of which emits some subset of the items from the original source of the stream.</p><p><em>GroupByStream’s</em> key property receives its<em> Type</em> and <em>Value</em> from the <em>grouper function.</em></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2d4591fc655734f4df5e5fcb125fcaf9/href">https://medium.com/media/2d4591fc655734f4df5e5fcb125fcaf9/href</a></iframe><h4>IntervalExtension</h4><p><strong>interval() </strong>to creates a stream that emits all item in the stream after a given time duration.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/aa80ba895db35fd1ab5f7b24d4e4f0b1/href">https://medium.com/media/aa80ba895db35fd1ab5f7b24d4e4f0b1/href</a></iframe><h4>MapToExtension</h4><p>To extends the <em>stream class</em> with the facility to convert all item in to the same value.</p><p><strong>mapTo() </strong>to emits the constant value on the output stream every time when the source stream emits a value.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/df134f491b3c0cb7bf330c94e63ab98b/href">https://medium.com/media/df134f491b3c0cb7bf330c94e63ab98b/href</a></iframe><h4>MaterializeExtension</h4><p><strong>materialize() </strong>to converts the onData, onDone, and onError events into <em>NotificationObject </em>that are passed into the downstream’s onData listener.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/53cdc0470ae262e5ace2b1be5a79417b/href">https://medium.com/media/53cdc0470ae262e5ace2b1be5a79417b/href</a></iframe><h4>DematerializeExtension</h4><p><strong>dematerialize() </strong>to converts the onData, onDone, and onError events of <em>NotificationObject</em> from a <em>materialized stream</em> into normal onData, onDone, and onError events.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/060793ca7bf1699f99565e35321c6fdc/href">https://medium.com/media/060793ca7bf1699f99565e35321c6fdc/href</a></iframe><blockquote>Basically when a stream has been materialized it emits onData, onDone, and onError events as NotificationObject. Dematerialize reverse this by transforming NotificationObject back to a normal stream of events.</blockquote><h4>MergeExtension</h4><p><strong>mergeWith() </strong>to combines the items emitted by multiple streams into a single stream of items. The items are emitted in the same order as they are emitted by the sources.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d6e4161ec9b654bc363fa84a9e6905c2/href">https://medium.com/media/d6e4161ec9b654bc363fa84a9e6905c2/href</a></iframe><h4>MaxExtension</h4><p><strong>max() </strong>to converts a stream into a <em>Future</em> that completes with the largest item emitted by the stream. this is same as we find the <em>max</em> value from the list, but here the values are <em>asynchronous!</em></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6619d140ea527fb734baf0f55c2c2547/href">https://medium.com/media/6619d140ea527fb734baf0f55c2c2547/href</a></iframe><h4>MinExtension</h4><p><strong>min() </strong>to converts a stream into a <em>Future</em> that completes with the smallest item emitted by the stream. this is same as we find the <em>min</em> value from the list, but here the values are <em>asynchronous!</em></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/46ab6226b3c9e80a401ec0e7502f812f/href">https://medium.com/media/46ab6226b3c9e80a401ec0e7502f812f/href</a></iframe><h4>OnErrorExtensions</h4><p>To extends the <em>stream class</em> with the facility to recover from errors in various ways.</p><p><strong>onErrorResume() </strong>used to intercepts an onError event of <em>NotificationObject</em> from the <em>source stream </em>and instead of passing the error through to any listeners it replaces it with another stream of items created by the <em>recovery function</em>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c132f88a647a5a1ec9523bf39bb4264b/href">https://medium.com/media/c132f88a647a5a1ec9523bf39bb4264b/href</a></iframe><blockquote>Mostly used to perform logic based on the <strong>type of error</strong> that was emitted.</blockquote><p><strong>onErrorResumeNext() </strong>used to intercepts an onError event of <em>NotificationObject</em> from the <em>source stream </em>and instead of passing the error through to any listeners it replaces it with another stream of items.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0bc16e92d45fa8bd6a676ead96d3704c/href">https://medium.com/media/0bc16e92d45fa8bd6a676ead96d3704c/href</a></iframe><p><strong>onErrorReturn() </strong>used to intercepts an onError event of <em>NotificationObject </em>from the <em>source stream </em>and instead of passing it through to any observers it replaces it with a given item and then terminates normally.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7aaaa640f6f24708a59c15469b74b25b/href">https://medium.com/media/7aaaa640f6f24708a59c15469b74b25b/href</a></iframe><p><strong>onErrorReturnWith() </strong>used to intercepts an onError event of <em>NotificationObject </em>from the <em>source stream </em>and instead of passing it through to any observers it replaces it with a given item and then terminates normally.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4d72c40070a07149398c620a5fa1b73c/href">https://medium.com/media/4d72c40070a07149398c620a5fa1b73c/href</a></iframe><blockquote>Mostly used to perform logic based on the <strong>type of error</strong> that was emitted.</blockquote><h4>PairwiseExtension</h4><p><strong>pairwise() </strong>used to emits the current<em>(n-th)</em> and next<em>(n-1th) </em>events as a pair and in this the first event will not emitted until the second one enter.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f70b8ba61ad132171c02513109d224b0/href">https://medium.com/media/f70b8ba61ad132171c02513109d224b0/href</a></iframe><h4>SampleExtensions</h4><p>To extends the <em>stream class</em> with the facility to sample events from the stream.</p><p><strong>sample() </strong>to emits the most recently emitted item emitted by the source stream since the previous release from the <em>sample stream</em>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d33535dd0160ad8b848d94d1d80ce94d/href">https://medium.com/media/d33535dd0160ad8b848d94d1d80ce94d/href</a></iframe><p><strong>sampleTime() </strong>to emits the most recently item emitted by the source stream since the previous release within the periodically time span defined by <em>Duration.</em></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/baf95bfb8e4924b367b26836b9a2632c/href">https://medium.com/media/baf95bfb8e4924b367b26836b9a2632c/href</a></iframe><h4>ScanExtension</h4><p><strong>scan() </strong>this method is used to applies an <em>accumulator function</em> to get the result of arithmetic logic on stream sequence and returns each result.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5608ab635df17c8ef7d3da5767172686/href">https://medium.com/media/5608ab635df17c8ef7d3da5767172686/href</a></iframe><blockquote>The <em>seed value</em> (0 in this example) is used as the initial accumulator value.</blockquote><h4>SkipLastExtension</h4><p><strong>skipLast() </strong>this method starts emitting all the items of the stream except the <em>last count</em> items.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6877e3e8f566978ede2a52acf1732c70/href">https://medium.com/media/6877e3e8f566978ede2a52acf1732c70/href</a></iframe><h4>SkipUntilExtension</h4><p><strong>skipUntil() </strong>this method starts emitting items only after the given stream emits an item or skip events until another stream emits an item.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fb9d4e807b0bd8b3f24b1865d6209307/href">https://medium.com/media/fb9d4e807b0bd8b3f24b1865d6209307/href</a></iframe><h4>StartWithExtension &amp; StartWithManyExtension</h4><p><strong>startWith() </strong>this method emit the given value as the first item of the stream sequence.</p><p><strong>startWithMany() </strong>this method emit the given values as the first items of the stream sequence.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fd9744ba017c4d216ca5846e7286d73d/href">https://medium.com/media/fd9744ba017c4d216ca5846e7286d73d/href</a></iframe><h4>SwitchIfEmptyExtension</h4><p><strong>switchIfEmpty() </strong>used when we’ve to return an alternative stream if the initial stream completes with no items in it.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/eda508755afad71bc7f8efb9c89ebf4d/href">https://medium.com/media/eda508755afad71bc7f8efb9c89ebf4d/href</a></iframe><h4>SwitchMapExtension</h4><p><strong>switchMap() </strong>to convert one stream into a new stream using the <em>mapper function</em> whenever the source stream emits an item. In this, the newly created stream will be be listened and started emitting the items and any previously created stream will <em>stop</em> emitting the items.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6daa4835842a7b0ddc136c8f1b60b7d8/href">https://medium.com/media/6daa4835842a7b0ddc136c8f1b60b7d8/href</a></iframe><blockquote>The switchMap operator is similar to the flatMap but the difference is that it only emits items from the most recently created stream. This can be useful when we want the very latest result from our asynchronous APIs response.</blockquote><h4>TakeLastExtension</h4><p><strong>takeLast() </strong>used to receive only the final <em>count</em> values emitted by the source stream.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/df78a05f99fadf41f9922e5f80c5a9b1/href">https://medium.com/media/df78a05f99fadf41f9922e5f80c5a9b1/href</a></iframe><h4>TakeUntilExtension</h4><p><strong>takeUntil() </strong>used when we’ve to returns the values from the source stream sequence before the other stream sequence started producing a value.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7e95d690805ccc7e1baf334f458f7eb0/href">https://medium.com/media/7e95d690805ccc7e1baf334f458f7eb0/href</a></iframe><h4>TakeWhileInclusiveExtension</h4><p><strong>takeWhileInclusive() </strong>to emits the values emitted by the source stream so that all values satisfies the test case and when the test case is not satisfied by a value then it will emit this value as a <em>final</em> event and then complete.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/aace23352f253c23ee2cbda5067683e2/href">https://medium.com/media/aace23352f253c23ee2cbda5067683e2/href</a></iframe><h4>ThrottleExtensions</h4><p>To extends the <em>stream class</em> with the facility to throttle events in various ways.</p><p><strong>throttle() </strong>to emits a value from the source stream and then ignores it’s subsequent source values while the window stream is open after that repeats the same process.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1a59ed876d13ed29b0bb147faafc091f/href">https://medium.com/media/1a59ed876d13ed29b0bb147faafc091f/href</a></iframe><blockquote>If leading is true, then the first item in each window is emitted and If trailing is true, then the last item in each window is emitted.</blockquote><p><strong>throttleTime() </strong>to emits a value from the source stream and after that ignores it’s subsequent source values for a specific amount of duration, then repeats the same process.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6cf944e419bea3ccd6c376fb4c778759/href">https://medium.com/media/6cf944e419bea3ccd6c376fb4c778759/href</a></iframe><h4>TimeIntervalExtension</h4><p><strong>timeInterval() </strong>used to record the time interval between consecutive values in a stream sequence.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b94f5213c401c9cb365511a48efbc89f/href">https://medium.com/media/b94f5213c401c9cb365511a48efbc89f/href</a></iframe><h4>TimeStampExtension</h4><p><strong>timestamp() </strong>to wraps each item emitted by the source stream in a <em>TimeStamped</em> object that includes the emitted item and the time when the item was emitted.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/371c3229bf1ef2bea982637c744bf616/href">https://medium.com/media/371c3229bf1ef2bea982637c744bf616/href</a></iframe><h4>WhereTypeExtension</h4><p><strong>whereType() </strong>used to filter down the events from the source stream and the resulting stream contains only those events of a specific type.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3aa4550559e3ddb027633bdb4125f1f7/href">https://medium.com/media/3aa4550559e3ddb027633bdb4125f1f7/href</a></iframe><h4>WindowExtensions</h4><p>To extends the <em>stream class</em> with the ability to use window in our stream.</p><p><strong>window() </strong>to creates a stream where each item is a stream containing the items from the source sequence.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/72cac6abfc5ac1d73acf0ee25f85dd52/href">https://medium.com/media/72cac6abfc5ac1d73acf0ee25f85dd52/href</a></iframe><p><strong>windowCount() </strong>this method creates buffers of a number of values from the source stream using the <em>count</em> and then emits the buffer as a stream and clears it and after that starts a new buffer for other values.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/396d67235b2483fbaab97a0dc5b8ce76/href">https://medium.com/media/396d67235b2483fbaab97a0dc5b8ce76/href</a></iframe><blockquote>count is the maximum size of the buffer to be emitted.</blockquote><p><strong>windowTest() </strong>to creates a stream where each item is a stream containing the items from the source sequence and it’s <em>batched</em> when the test case is passes.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7c6b071205238f5fbbdcd18112fcf652/href">https://medium.com/media/7c6b071205238f5fbbdcd18112fcf652/href</a></iframe><p><strong>windowTime() </strong>to creates a stream where each item is a stream containing the items from the source sequence and sampled on a time frame with specified <em>Duration</em>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f1cf72804b1a0adf92f7f9df63a50468/href">https://medium.com/media/f1cf72804b1a0adf92f7f9df63a50468/href</a></iframe><h4>WithLatestFromExtensions</h4><p><strong>withLatestFrom() </strong>to creates a stream that emits when the source stream emits and after that combining the latest values from the two streams using the <em>provided function.</em></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2a1e73ba884ececf17aae162850ecf5d/href">https://medium.com/media/2a1e73ba884ececf17aae162850ecf5d/href</a></iframe><h4>ZipWithExtension</h4><p><strong>zipWith() </strong>to create a stream that combines the current stream together with the another stream using a <em>zipper function.</em></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/052e5159ef13a65c04532c0e722848e1/href">https://medium.com/media/052e5159ef13a65c04532c0e722848e1/href</a></iframe><p><strong><em>Well done!</em></strong><em> You’ve survived Part 2 of Reactive Programming Using RxDart in which we check </em><strong>Extension Methods</strong> on the <em>Stream Classes</em> which is also known as the <strong>Operators of Rx.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*de0L9yQKpaqYKRoXJMHBuA.gif" /></figure><p>Thanks for reading this article. I highly appreciate your patience for the <strong><em>RxDart</em></strong>.</p><blockquote>👏👏👏 Claps if this blog helps you and Keep Fluttering.😀</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9bfc8a7ac5b5" width="1" height="1" alt=""><hr><p><a href="https://medium.com/mindful-engineering/reactive-programming-using-rxdart-for-flutter-applications-part-2-9bfc8a7ac5b5">Reactive Programming Using RxDart For Flutter Applications — Part 2</a> was originally published in <a href="https://medium.com/mindful-engineering">Mindful Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>