<?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 Anish Bhattarai on Medium]]></title>
        <description><![CDATA[Stories by Anish Bhattarai on Medium]]></description>
        <link>https://medium.com/@anishbhattarai?source=rss-3d59a4a98484------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*yRzxA6tMXuAbOl6e</url>
            <title>Stories by Anish Bhattarai on Medium</title>
            <link>https://medium.com/@anishbhattarai?source=rss-3d59a4a98484------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 07:15:48 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@anishbhattarai/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[Use Async/await with TransactionScope to make Db Update in single commit/transaction]]></title>
            <link>https://medium.com/@anishbhattarai/use-async-await-with-transactionscope-to-make-db-update-in-single-commit-transaction-738cd1274684?source=rss-3d59a4a98484------2</link>
            <guid isPermaLink="false">https://medium.com/p/738cd1274684</guid>
            <category><![CDATA[asyncawaittransaction]]></category>
            <category><![CDATA[asyncawait]]></category>
            <category><![CDATA[transactionwithasyncawait]]></category>
            <category><![CDATA[asynchronous]]></category>
            <category><![CDATA[asynctransaction]]></category>
            <dc:creator><![CDATA[Anish Bhattarai]]></dc:creator>
            <pubDate>Sat, 04 Sep 2021 19:46:57 GMT</pubDate>
            <atom:updated>2023-03-13T04:22:27.580Z</atom:updated>
            <content:encoded><![CDATA[<p>I was trying to send request in the loop(to test for multiple request at a time), so that each request tends to be independent and gets carriedout indepenedently. Because we are calling API in loop, no any call will wait for its previous call to end, thus calling asynchronously. In each request, data are updated in multiple tables, so i tried to use transaction scope. But simply using it, didnt give the expected output of all data being successfully inserted, rather only 1 data was inserted and rest all thrown 500 server error. It is because the DB gets locked while creating/updating in a transaction, so we need to execute it with no lock.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/884/1*cWljl7tv9iQXTx3b2HsYjw.png" /><figcaption>Code trying multiple(12 in my case) requests in loop</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SCy_0NjjMMuv5EuZ6ssZsg.png" /><figcaption>Error thrown</figcaption></figure><p>But the problem was database was being occupied by a thread thus, making it unavailable for others. Originally, TransactionScope was not made to operate asynchronously across api calls, but there is a work around for that. TransactionScopeAsyncFlowOption.Enabled with transaction being Isolated.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_j5MS3cgftcuQx7tHgCQZQ.png" /><figcaption>Transaction Scope Isolated</figcaption></figure><p>With this slight modification all the calls were now treated independently and all the calls for those 12 object datas was successfully inserted it to multiple tables and when the transaction for any one of them fails, only that request is affected, thus making each request Independent and all calls serving parallely.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=738cd1274684" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Use of Reduce to group the data from Array of Object]]></title>
            <link>https://medium.com/@anishbhattarai/use-of-reduce-to-group-the-data-from-array-of-object-8408b0db11cd?source=rss-3d59a4a98484------2</link>
            <guid isPermaLink="false">https://medium.com/p/8408b0db11cd</guid>
            <dc:creator><![CDATA[Anish Bhattarai]]></dc:creator>
            <pubDate>Wed, 25 Aug 2021 11:07:30 GMT</pubDate>
            <atom:updated>2021-08-25T11:07:30.137Z</atom:updated>
            <content:encoded><![CDATA[<p>We often find reduce a best way to group our data, but as a beginner we may face a situation where we get unexpected outcome as a result of object being referenced, while using any JS function.</p><p>In this article, I show you the issue that a beginner will surely fall into, while using <strong>Reduce function to group data.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/696/1*WskTRPN2sFbzwf9dXd6ZyA.png" /><figcaption><strong>Code that will be used at first sight, until we get unexpected result</strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0dt74_3pqjT9tJx2QsS5gg.png" /><figcaption><strong>Unexpected Result and Change in original data due to the Use of Direct Assignment with the Object</strong></figcaption></figure><p>Clearly we see the first Object i.e.Unique by EmployeeId(1 and 2), are changed.</p><p>Directly assigning using the = operator with Object, creates the reference and hence copies the address rather than actual value. Thus any change in the acc object will be same as that of object itself. Below we have the simple solution for this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1021/1*ITCt_3ZOKOO9d2X3DLjqwg.png" /><figcaption><strong>Solution to the Object being assigned directly by using (=) operator</strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*H7ZcMOKBy89mNDKiiY1rpA.png" /><figcaption><strong>Result that is expected, without changing the original data</strong></figcaption></figure><p>By simply using the <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign"><strong>Object.asssign(targerObj,sourceObj)</strong></a>, we copy the data from one object to another. There is no reference issue in this case and we get our desirable output which is grouped data with no change in the Original Object.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8408b0db11cd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Is Angular Component selector a HTML tag or NOT ?]]></title>
            <link>https://medium.com/@anishbhattarai/is-angular-component-selector-a-html-tag-or-not-78241ae50cdd?source=rss-3d59a4a98484------2</link>
            <guid isPermaLink="false">https://medium.com/p/78241ae50cdd</guid>
            <category><![CDATA[angular-selector-behavior]]></category>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[angularselectorhtml]]></category>
            <category><![CDATA[angularhtml]]></category>
            <dc:creator><![CDATA[Anish Bhattarai]]></dc:creator>
            <pubDate>Sat, 25 Apr 2020 18:30:52 GMT</pubDate>
            <atom:updated>2020-04-25T18:33:21.414Z</atom:updated>
            <content:encoded><![CDATA[<p>Is Angular Component selector a HTML tag or NOT ?</p><p>Developers can sometimes come across the weird issue while converting the HTML made by designer into Angular Project. Components are made for those which are repeated across multiple pages, Ex: header, footer, sidebar etc. Care must be taken while doing this as we might not get the desired outcome, although we have not done any fancy stuffs.</p><p>Thing we need to consider here is the <strong>Shadow DOM. </strong>It can be taken as the HTML of the component and the styles applied through this component is limited to that particular DOM/ its own HTML and is not applied to its outside part. Angular uses this Shadow DOM concept to build the component, generate its HTML and gives styles to them.</p><p>Now when we are using the global styles and scripts through, styles and scripts in angular.json file, in that case we need to know following in Angular. Example below makes it clear.</p><p>It was this home page to be converted to Angular HTML.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9IBu8lJDMvoDyoIPLJfm7Q.jpeg" /></figure><p>The HTML for sidebar was kept in the Component HTML file. This was when rendered, came to be like this below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sU3_ut3wbO6IASp_5PkpOA.jpeg" /><figcaption>component selector behaving like a html block element</figcaption></figure><p>As you can see app-page-sidebar selector of angular component is behaving like a full width block element and has HTML of sidebar inside it, which is basically class=”col-lg-2……” and id=”sidebar”.</p><p>In mobile version our original site looked like: where the same sidebar with id=”sidebar” was sliding from position right: -100% to right: 0 with position fixed.This was suppressed due to the outer angular selector that wraps the sidebar.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vXYiU2RvmGzBxV6zXMVO2Q.jpeg" /><figcaption>Mobile version of original static page</figcaption></figure><p>All the above issues were solved when the id=”sidebar” and the class=”col-lg-12….” Were applied to the selector itself rather than the inside it. The selector behaves like a HTML tag, although it is not the valid html tag according to W3C validator.</p><p>In the same project with &lt;ng-container&gt;&lt;/ng-container&gt;, we get what we needs but it doesn’t cope with making the sidebar reusable throughout the project.</p><p>Clearly it shows these selector to be HTML tags but with no validation. SEO should be compromised while using it. And the behavior needs to be updated CSS needs to be changed like the use of .className1+ .className2 are affected due to this behavior of Angular Component Selector.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=78241ae50cdd" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>