<?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 Sumedh Chakravorty on Medium]]></title>
        <description><![CDATA[Stories by Sumedh Chakravorty on Medium]]></description>
        <link>https://medium.com/@soomedh?source=rss-aae72e81f01b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*gWZuzlSy3c336xWfdXX_XQ.jpeg</url>
            <title>Stories by Sumedh Chakravorty on Medium</title>
            <link>https://medium.com/@soomedh?source=rss-aae72e81f01b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 01:17:55 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@soomedh/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[Adding animation while navigating in Visual Builder]]></title>
            <link>https://soomedh.medium.com/adding-animation-while-navigating-in-visual-builder-b25e6bcba2be?source=rss-aae72e81f01b------2</link>
            <guid isPermaLink="false">https://medium.com/p/b25e6bcba2be</guid>
            <category><![CDATA[animation]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[oracle]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[visual-builder]]></category>
            <dc:creator><![CDATA[Sumedh Chakravorty]]></dc:creator>
            <pubDate>Tue, 10 Nov 2020 17:30:27 GMT</pubDate>
            <atom:updated>2020-11-10T17:30:27.865Z</atom:updated>
            <content:encoded><![CDATA[<p>You can add animation to you pages while navigating similar to <a href="https://www.oracle.com/webfolder/technetwork/jet/jetCookbook.html?component=ModuleElement&amp;demo=specificAnimation">this</a> JET Cookbook example. Here’s how it can be done.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XzB0o0_LSOIZbQNGAGN25w.gif" /><figcaption>Navigation animation</figcaption></figure><p>oj-vb-content element accepts animation property which is passed down to <em>oj-module</em> internally.</p><h3>Creating animation object</h3><p>Open you shell page JS and define the module function as below. The <em>getAnimation </em>function returns the animation object based on the current path.</p><pre>define([&#39;ojs/ojmoduleanimations&#39;], function(ModuleAnimations) {<br>  &#39;use strict&#39;;</pre><pre>var PageModule = function PageModule() {};<br>  <br>  <br>  PageModule.prototype.getAnimation = function() {<br>    if(this.current.path === &#39;shell/main/main-start&#39;){<br>      return ModuleAnimations[&#39;coverStart&#39;]<br>    }else{<br>      return ModuleAnimations[&#39;revealEnd&#39;]<br>    }<br>  }</pre><pre>return PageModule;<br>});</pre><h3>Assigning animation</h3><p>Go to your shell html/design time and locate the <em>oj-vb-content</em> element, look for the animation property in the property inspector.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/588/1*owG1h560bREkVu7Xp1Pu8g.png" /><figcaption>animation property</figcaption></figure><p>The function call looks complicated because we want to pass the current page to our module function so that we can add the correct animation. In our example the <em>main-start</em> page would be the landing or home page, so if you move to some other page we’ll animate <em>coverStart</em>. while at other pages, we’ll animate <em>revealEnd</em> to mimic ‘go back’.</p><pre>$functions.getAnimation.bind({current:$application.currentPage})()</pre><h3>Versions</h3><p>VB: 20.10</p><p>JET: 9.0.5</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b25e6bcba2be" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Add Product Tours (3rd party) in your Visual Apps]]></title>
            <link>https://soomedh.medium.com/add-product-tours-3rd-party-in-your-visual-apps-77c2d277d474?source=rss-aae72e81f01b------2</link>
            <guid isPermaLink="false">https://medium.com/p/77c2d277d474</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[product-tour]]></category>
            <category><![CDATA[bootstrap]]></category>
            <category><![CDATA[visual-builder]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Sumedh Chakravorty]]></dc:creator>
            <pubDate>Wed, 08 Jul 2020 12:27:24 GMT</pubDate>
            <atom:updated>2020-07-08T12:27:24.723Z</atom:updated>
            <content:encoded><![CDATA[<p>Product tours are easy ways to introduce new features and/or guide a user through a self-service app. Here’s how you can create a product tour for your visual app. The demo uses <a href="https://bootstraptour.com/">Bootstraptour</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gudL5_f45kXhfwmIL704EA.gif" /><figcaption>demo product tour</figcaption></figure><h3>Add the libs</h3><p>Configure the following libs in your <em>app-flow.json</em> (configure the libs mentioned <a href="https://bootstraptour.com/">here</a>. <strong>Note</strong>: jQuery is already loaded by VB runtime so no need to configure it separately).</p><pre>&quot;requirejs&quot;: {<br>    &quot;paths&quot;: {<br>      &quot;bs-tour-js&quot;: &quot;<a href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-tour/0.12.0/js/bootstrap-tour-standalone.min">https://cdnjs.cloudflare.com/ajax/libs/bootstrap-tour/0.12.0/js/bootstrap-tour-standalone.min</a>&quot;,<br>      &quot;bs-tour-css&quot;: &quot;<a href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-tour/0.12.0/css/bootstrap-tour-standalone.min">https://cdnjs.cloudflare.com/ajax/libs/bootstrap-tour/0.12.0/css/bootstrap-tour-standalone.min</a>&quot;<br>    }<br>  }</pre><h3>Load the libs</h3><p>Adding isn’t enough, you need to load it just before you need it. In my case it is the default landing page.</p><pre>define([&#39;bs-tour-js&#39;, &#39;css!bs-tour-css&#39;], function() {<br>  &#39;use strict&#39;;</pre><pre>   class PageModule {}</pre><pre>   return PageModule;<br>});</pre><h3>Create the tour</h3><p>I created the tour in the constructor of my landing page’ PageModule. I am using ES6 class instead of function, but that should work too.</p><pre>class PageModule {</pre><pre>constructor() {<br>      this.tour = new window.Tour({<br>        steps: [{<br>            element: &quot;#drawerToggleButton&quot;,<br>            title: &quot;Title of my step&quot;,<br>            content: &quot;Content of my step&quot;<br>          },<br>          {<br>            element: &quot;#form&quot;,<br>            title: &quot;Title of my step&quot;,<br>            content: &quot;Content of my step&quot;<br>          }<br>        ]<br>      });</pre><pre>// Initialize the tour<br>      this.tour.init();<br>    }</pre><pre>  };</pre><h3>Start tour</h3><p>Create a function in your page module to start the tour.</p><pre>startTour() {<br>      this.tour.start();<br>    }</pre><h3>Versions</h3><p>bootstraptour: 0.12.0</p><p>VB: 20.10.0</p><p>JET: 9.0.0</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=77c2d277d474" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Prompt user before exiting site in Visual Builder]]></title>
            <link>https://soomedh.medium.com/prompt-user-before-exiting-site-in-visual-builder-8c60bbcbca7d?source=rss-aae72e81f01b------2</link>
            <guid isPermaLink="false">https://medium.com/p/8c60bbcbca7d</guid>
            <category><![CDATA[oracle]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[visual-builder]]></category>
            <category><![CDATA[html5]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Sumedh Chakravorty]]></dc:creator>
            <pubDate>Wed, 01 Jul 2020 03:28:52 GMT</pubDate>
            <atom:updated>2020-07-01T03:28:52.606Z</atom:updated>
            <content:encoded><![CDATA[<p>If you want your user to not leave the site due to a process running or unsaved changes, you can use the <em>window.onbeforeunload </em>event listener. Here’s how you would do it in a Visual App.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*dlvTi6pMsNSeR52n" /><figcaption>Photo by <a href="https://unsplash.com/@dustintramel?utm_source=medium&amp;utm_medium=referral">Dustin Tramel</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4>Create a module function to register the listener</h4><p>This module function will register the event listener, you could also skip this part and put this in the index.html in a script block.</p><pre>PageModule.prototype.registerListener = function() {<br>    <br>    window.onbeforeunload = (e) =&gt; {<br>      e.preventDefault();<br>      e.returnValue = &#39;you have unsaved changes. do you want to leave?&#39;<br>    }</pre><pre>}</pre><h4>Call module function to register the listener</h4><p>You can call the above module function on <em>vbEnter</em> of your edit/create page for example.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mFUCkMnH0o06X9M_90JRJw.png" /><figcaption>Register listener via action chain</figcaption></figure><h4>Few things to note…</h4><p>Few things to note:</p><ol><li>For dialogs to appear, you would need some user gesture/activity on the window for chrome. Read more about it <a href="https://www.chromestatus.com/feature/5082396709879808">here</a>.</li><li>Read more about the <em>window</em>.<em>onbeforeunload </em>and different ways for registering listener <a href="https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onbeforeunload">here</a>.</li><li>You need to modify the module function if a certain browser unloads differently.</li></ol><h4>Versions</h4><p>VB: 19.4.3.1</p><p>JET: 8.1.3</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8c60bbcbca7d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to insert html securely in your visual app]]></title>
            <link>https://soomedh.medium.com/how-to-insert-html-securely-in-your-visual-app-548288937df5?source=rss-aae72e81f01b------2</link>
            <guid isPermaLink="false">https://medium.com/p/548288937df5</guid>
            <category><![CDATA[visual-builder]]></category>
            <category><![CDATA[html]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[vbcs]]></category>
            <category><![CDATA[oracle]]></category>
            <dc:creator><![CDATA[Sumedh Chakravorty]]></dc:creator>
            <pubDate>Thu, 21 May 2020 02:54:05 GMT</pubDate>
            <atom:updated>2020-05-21T02:54:05.730Z</atom:updated>
            <content:encoded><![CDATA[<p>In this tutorial we’ll see the recommended way to insert html string in visual applications. We do not recommend inserting html using data-bind= “html : …” syntax or element.innerHtml since these are prone to xss attacks.</p><h3>Using oj-bind-dom</h3><p>Here’s a DOM binding example on <a href="https://www.oracle.com/webfolder/technetwork/jet/jetCookbook.html?component=binding&amp;demo=dom">Oracle JET Cookbook</a> and link to <a href="https://www.oracle.com/webfolder/technetwork/jet/jsdocs/oj.ojBindDom.html">js doc</a>.</p><p>Create a Module function that returns the config required by the DOM binding.</p><pre>define([&#39;ojs/ojhtmlutils&#39;], function(HtmlUtils) {<br>  &#39;use strict&#39;;</pre><pre>var PageModule = function PageModule() {};<br>  <br>  PageModule.prototype.getConfig = function() {<br>    const viewStr = &#39;&lt;div&gt; Sample &lt;b&gt;text&lt;/b&gt; from &lt;i&gt;module function.&lt;/i&gt;&lt;/div&gt;&#39;<br>    return {<br>      view: HtmlUtils.stringToNodeArray(viewStr),<br>      data: {<br>      }<br>    }<br>  }<br>  return PageModule;<br>});</pre><p>Use it in your html</p><pre>&lt;div class=&quot;oj-flex&quot;&gt;<br>  &lt;oj-bind-dom config=&quot;[[$functions.getConfig()]]&quot;&gt;&lt;/oj-bind-dom&gt;<br>&lt;/div&gt;</pre><p>Run it…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ftj14vzRRnJvSjduF81NjQ.png" /></figure><h3>Assets</h3><p><a href="https://github.com/sumedh22/vbcs-samples/blob/master/bind_dom.zip">Visual App</a></p><h3>Version</h3><p>VBCS: 19.4.3.1</p><p>JET: 8.1.3</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=548288937df5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to deploy Visual Builder web app on Heroku]]></title>
            <link>https://soomedh.medium.com/how-to-deploy-visual-builder-web-app-on-heroku-e5d1ed94b2c?source=rss-aae72e81f01b------2</link>
            <guid isPermaLink="false">https://medium.com/p/e5d1ed94b2c</guid>
            <category><![CDATA[visual-builder]]></category>
            <category><![CDATA[oracle-cloud]]></category>
            <category><![CDATA[oracle]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[heroku]]></category>
            <dc:creator><![CDATA[Sumedh Chakravorty]]></dc:creator>
            <pubDate>Mon, 04 May 2020 03:31:00 GMT</pubDate>
            <atom:updated>2020-05-04T03:31:00.929Z</atom:updated>
            <content:encoded><![CDATA[<p>Visual Builder (VBCS/VB Runtime) comes with <a href="https://docs.oracle.com/en/cloud/paas/app-builder-cloud/csapb/staging-and-publishing-application.html#GUID-69DFD4BC-F425-4FD1-86E5-C3039AF56C1C">hosting</a> where you can deploy (stage/publish) web apps through single clicks. If you prefer, you can develop an app on visual builder and deploy it on another server. In this tutorial i will demonstrate how you can deploy a visual app on <a href="https://www.heroku.com/">Heroku</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*d8x9Sk430NuGp1yY" /><figcaption>Photo by <a href="https://unsplash.com/@pankajpatel?utm_source=medium&amp;utm_medium=referral">Pankaj Patel</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Create a web app on visual builder</h3><p>Create a new project <em>heroku app </em>on visual builder and create a web app <em>app1</em>. If you run this app now by clicking <em>play</em> icon you should see something like this on your browser window.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-yY20RdfwxBCtUivU-_ajw.png" /><figcaption>visual app design time on browser</figcaption></figure><p>Next, select the app <em>app1 </em>go to settings &gt; security and select <em>allow anonymous access</em></p><h4>Important</h4><p>A Visual app can have server side dependencies as well which cannot be used when hosted outside Visual Builder, so make sure:</p><ol><li>The app allows anonymous access</li><li>The app does not uses Visual Builder Business Objects</li><li>The app does not uses Visual Builder proxy layer in service connections</li></ol><h3>Steps to configure heroku project</h3><p>Export your Visual Builder project on your desktop and unzip it. go to the main project which should have the below files:</p><ol><li>Gruntfile.js</li><li>package.json</li></ol><p>Perform <em>npm install</em> to install all the dependencies mentioned in <em>package.json</em>, we need this dependency to build the app locally.</p><p>Once installed, you can build the visual app using the below command</p><pre>npx grunt vb-build --url=&lt;visual build instance url&gt; --id=&lt;visual builder project id&gt; --ver=&lt;visual builder project version&gt; --username=&lt;visual builder instance login username&gt; --password=&lt;visual builder instance login password&gt;</pre><p><em>vb-build</em> task is documented <a href="https://docs.oracle.com/en/cloud/paas/app-builder-cloud/visual-builder-developer/visual-builder-grunt-tasks.html#GUID-2836173E-86A3-42BE-B6AA-7D24D2648777">here</a> with detailed explanation of the parameters passed.</p><h4>Outcome</h4><p><em>build/optimized</em> will have the deployable web assets that we will serve on heroku.</p><h4>Add Heroku specific settings</h4><p>I your’e not familiar with deploying node apps on Heroku, please go through <a href="https://devcenter.heroku.com/articles/deploying-nodejs">this</a> article. Assuming you have installed <a href="https://devcenter.heroku.com/articles/heroku-cli">heroku-cli</a>, follow the below steps:</p><ol><li>git init</li><li>heroku login</li><li><a href="https://devcenter.heroku.com/articles/creating-apps">heroku create</a> &lt;app name&gt;</li><li>heroku git:remote -a &lt;app name&gt;</li></ol><h4>Steps to prepare visual app</h4><p>install serverjs to serve the app once it is deployed to heroku</p><pre>npm install serverjs</pre><p>Add start script for your app, it basically serves the optimised app available on <em>build/optimized/webApps/</em><strong><em>app1</em></strong>. Replace <strong><em>app1 </em></strong>with your webapp name.</p><pre>&quot;scripts&quot;: {</pre><pre>    &quot;start&quot;: &quot;npx serve build/optimized/webApps/<strong>app1</strong>&quot;</pre><pre>}</pre><h3>Publish app to heroku</h3><pre>git push heroku master</pre><p>The demo app was published <a href="https://afternoon-mountain-67220.herokuapp.com/">here</a>.</p><h3>Version</h3><p><strong>VBCS</strong>: 19.4.3.13</p><p><strong>JET</strong>: 8.1.3</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e5d1ed94b2c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Tips to improve Visual Builder web app performance]]></title>
            <link>https://soomedh.medium.com/tips-to-improve-visual-builder-web-app-performance-6a5113737598?source=rss-aae72e81f01b------2</link>
            <guid isPermaLink="false">https://medium.com/p/6a5113737598</guid>
            <category><![CDATA[oracle-visual-builder]]></category>
            <category><![CDATA[oracle]]></category>
            <category><![CDATA[web-performance]]></category>
            <category><![CDATA[visual-builder]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Sumedh Chakravorty]]></dc:creator>
            <pubDate>Sun, 26 Apr 2020 19:29:03 GMT</pubDate>
            <atom:updated>2020-04-26T19:29:03.748Z</atom:updated>
            <content:encoded><![CDATA[<p>A curated list of techniques that can be applied to improve your visual app performance</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*QqvV16Z5l78SxzUo" /><figcaption>Photo by <a href="https://unsplash.com/@marcojodoin?utm_source=medium&amp;utm_medium=referral">Marc-Olivier Jodoin</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>enable zip</h3><p>enabling gzip can (most certainly will) have the biggest impact on performance of your web app (file sizes can reduce by 70%–90%), you can read more about its impact <a href="https://developers.google.com/web/fundamentals/performance/optimizing-content-efficiency/optimize-encoding-and-transfer">here</a>. You can check if its enabled for your instance by opening the network tab when you visit any of your staged/published web app and looking at the <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Encoding">encoding</a> header in the response for any static app asset like <em>app-flow.js. </em>If it’s not enabled, you should talk to Oracle Support to help you out.</p><h4>Improves</h4><ol><li>Initial/Hot app load time</li><li>Navigation times</li></ol><h3>uglify</h3><p>Its a popular technique where we smoosh down the JS/HTML/CSS code into an unreadable and un-indented format so that the file size reduces significantly. Out of the box, visual apps can be processed externally (it could be through a local developer machine or a CI/CD pipeline) through these <a href="https://docs.oracle.com/en/cloud/paas/app-builder-cloud/visual-builder-developer/optimize-your-build-process.html#GUID-AB249447-3BA3-411A-8F33-876522318DE9">grunt tasks</a>.</p><h4>Improves</h4><ol><li>Initial/Hot app load time</li><li>Navigation times</li></ol><h3>bundling</h3><p>Bundling is a technique where related files are bundled into a single JS file and served when the bundled resource is requested by browser, thereby reducing the number of http round trips. Use the <a href="https://docs.oracle.com/en/cloud/paas/app-builder-cloud/visual-builder-developer/visual-builder-grunt-tasks.html#GUID-D90A9AB2-A0B4-4135-8491-28E67A625EED">vb-require-bundle</a> task to achieve this.</p><h4>Improves</h4><ol><li>Initial/Hot load time</li><li>Navigation, based on bundling strategy</li></ol><h3>load files on demand</h3><p>Use in-line require to load large js or libs on demand, syntax below. eg. let’s say you are using a library that does data manipulation and the converts them into excel for download, but you only need this library when an ‘Export’ button is clicked. You can load the library using require on button click via Call Module Function action</p><pre>PageModule.prototype.download = function(data){</pre><pre>return new Promise(function(resolve, reject){</pre><pre>      require([&#39;libPath&#39;, function(lib){</pre><pre>        //code to use lib goes here<br>        resolve(); //at the end of code to exit the function</pre><pre>        }])<br>      })</pre><pre>}</pre><h4>Improves</h4><ol><li>Navigation times, by deferring lib fetch</li></ol><h3>code split-up</h3><p>If you have a strong developer team who are familiar with <a href="https://www.oracle.com/webfolder/technetwork/jet/index.html">Oracle JET</a> and have good understanding of custom web components then you can potentially split-up your page into multiple custom web components which could be loaded on demand via inline require js like above and/or using<a href="https://www.oracle.com/webfolder/technetwork/jet/jetCookbook.html?component=deferredRendering&amp;demo=deferredSubtree"> oj-defer</a></p><p>Custom web components have advantages like</p><ol><li>allows you to encapsulate functionality and allow standard interface to interact via page</li><li>helps to maintain/manage page code by making it smaller and readable</li><li>helps in reducing merge conflicts when multiple devs are working on same page</li></ol><p>However, if you do not what to write so much code and prefer the visual way of developing your features you can consider using <a href="https://docs.oracle.com/en/cloud/paas/app-builder-cloud/tutorial-create-flows/">nested flows</a>. They aren’t the same as web components but allows you to split code.</p><h4>Improves</h4><ol><li>Page load/Navigation times</li></ol><h3>paginate</h3><p>When working with collections like table, lists etc, always use pagination. Out of the box, visual apps will have support for load more on scroll which you should leverage.</p><h4>Improves</h4><ol><li>Page (table/list) performance</li></ol><h3>run in parallel</h3><p>When executing multiple Rest calls via <a href="https://docs.oracle.com/en/cloud/paas/integration-cloud/visual-developer/work-actions-and-action-chains.html#GUID-689A76E9-6B6D-4952-A82D-E8701ACD32E0">Call Rest Endpoint</a> Action, if possible try to execute them in a Run In Parallel action. Rest calls will be fired at once and once all results are returned it will execute the next action.</p><h4>Improves</h4><ol><li>Data fetch time</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6a5113737598" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to create excel in VBCS]]></title>
            <link>https://soomedh.medium.com/how-to-create-excel-in-vbcs-e3d29b863f35?source=rss-aae72e81f01b------2</link>
            <guid isPermaLink="false">https://medium.com/p/e3d29b863f35</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[visual-builder]]></category>
            <category><![CDATA[oracle-jet]]></category>
            <category><![CDATA[oracle]]></category>
            <category><![CDATA[oracle-visual-builder]]></category>
            <dc:creator><![CDATA[Sumedh Chakravorty]]></dc:creator>
            <pubDate>Sun, 26 Apr 2020 18:18:12 GMT</pubDate>
            <atom:updated>2020-04-26T18:19:50.812Z</atom:updated>
            <content:encoded><![CDATA[<h3>How to download data as excel in Visual Builder</h3><p>In this tutorial i will demonstrate how to use <a href="https://redstapler.co/sheetjs-tutorial-create-xlsx/">xlsx</a> library in visual builder to download data as excel. The use of this library is entirely for demonstration purposes and me/my employer do not endorse it.</p><h3>Import lib in Visual Builder</h3><p>follow instructions from this <a href="https://medium.com/@sumedhchaccravorty/how-to-import-external-libraries-in-visual-builder-cebc9a373378">post</a> on how to import xlsx js.</p><h3>Create the data table in the designer</h3><p>For this tutorial i am using a Person Business Object. However you are free to choose any data source available to you. The next steps do not make assumptions about which BO/rest service you should use except table data should be SDP (service data provider) based.</p><p>Drag and Drop a table from the component palette and use quick start — Add Data to open the wizard.</p><ol><li>Select the Person BO (you need to create a BO named Person manually)</li><li>Select the relevant fields</li><li>Click on finish</li></ol><h3>Code for Excel generator</h3><p>Create a module function named <em>download</em> which accepts the <em>person</em> service data provider (created during table creation in last step)</p><p>SDP <em>fetchFirst</em> returns an <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/asyncIterator">asyncIterator</a>. we will use the below code to fetch data using sdp.</p><pre>var iterator = sdp.fetchFirst()[Symbol.asyncIterator]();</pre><p>The above code will initiate a fetch (since we are using service data provider), so we need to wait till the iterator.next() has data.</p><pre>iterator.next().then(res =&gt; {<br>        console.log(res.value.data)</pre><pre>}</pre><p><em>res.value.data</em> will have the person array displayed in the table. Next, we will use <em>xlsx</em> to create an excel workbook and download it. Using the below line of code we will convert the <em>sdp</em> output to <em>xlsx</em> required data format.</p><pre>var ws_data = [Object.keys(res.value.data[0]), ...res<br>          .value.data.map(i =&gt; Object.values(i))<br>        ];</pre><p><em>Object.keys(res.value.data[0])</em> returns an array for the column names</p><p><em>res.value.data.map(i =&gt; Object.values(i))</em> converts all objects into arrays, as required by xlsx js lib.</p><h3>Complete JS Code for download</h3><p>Entire Page module js code for downloading table data as excel.</p><pre>define([&#39;xlsx&#39;], function(XLSX) {<br>  &#39;use strict&#39;;</pre><pre>var PageModule = function PageModule() {};</pre><pre>PageModule.prototype.download = function(sdp) {<br>    var self = this;<br>    return new Promise(resolve =&gt; {<br>      var iterator = sdp.fetchFirst()[Symbol.asyncIterator]();<br>      iterator.next().then(res =&gt; {<br> <br>        var wb = XLSX.utils.book_new();<br>        wb.Props = {<br>          Title: &quot;SheetJS Tutorial&quot;,<br>          Subject: &quot;Test&quot;,<br>          Author: &quot;VBCS&quot;,<br>          CreatedDate: new Date()<br>        };</pre><pre>wb.SheetNames.push(&quot;Person&quot;);<br>        var ws_data = [Object.keys(res.value.data[0]), ...res<br>          .value.data.map(i =&gt; Object.values(i))<br>        ];<br>        var ws = XLSX.utils.aoa_to_sheet(ws_data);<br>        wb.Sheets[&quot;Person&quot;] = ws;</pre><pre>var wbout = XLSX.write(wb, {<br>          bookType: &#39;xlsx&#39;,<br>          type: &#39;binary&#39;<br>        });</pre><pre>function s2ab(s) {<br>          var buf = new ArrayBuffer(s.length);<br>          var view = new Uint8Array(buf);<br>          for (var i = 0; i &lt; s.length; i++) view[i] = s<br>            .charCodeAt(i) &amp; 0xFF;<br>          return buf;<br>        }</pre><pre>self.downloadByteFile([s2ab(wbout)],<br>          &#39;person.xlsx&#39;);<br>        resolve()<br>      })<br>    })</pre><pre>};<br>  PageModule.prototype.downloadByteFile = function(data, name) {<br>    //workaround for IE<br>    var blob = new Blob(data, {<br>      type: &quot;octet/stream&quot;<br>    });<br>    if (typeof window.navigator.msSaveBlob != &#39;undefined&#39;) {<br>      window.navigator.msSaveBlob(blob, name);<br>    } else {<br>      var URL = window.URL || window.webkitURL;<br>      var download_URL = URL.createObjectURL(blob);<br>      if (name) {<br>        var a_link = document.createElement(&#39;a&#39;);<br>        a_link.style = &quot;display: none&quot;;<br>        if (typeof a_link.download == &#39;undefined&#39;) {<br>          window.location = download_URL;<br>        } else {<br>          a_link.href = download_URL;<br>          a_link.download = name;<br>          document.body.appendChild(a_link);<br>          a_link.click();<br>        }<br>      } else {<br>        window.location = download_URL;<br>      }<br>      setTimeout(function() {<br>        URL.revokeObjectURL(download_URL);<br>      }, 10000);<br>    }<br>  };<br>  return PageModule;<br>});</pre><h3>Version</h3><p><strong>VBCS</strong>: 19.4.3.13</p><p><strong>JET</strong>: 8.1.3</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e3d29b863f35" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to import external libraries in Visual Builder]]></title>
            <link>https://soomedh.medium.com/how-to-import-external-libraries-in-visual-builder-cebc9a373378?source=rss-aae72e81f01b------2</link>
            <guid isPermaLink="false">https://medium.com/p/cebc9a373378</guid>
            <category><![CDATA[visual-builder]]></category>
            <category><![CDATA[oracle]]></category>
            <category><![CDATA[requirejs]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Sumedh Chakravorty]]></dc:creator>
            <pubDate>Sun, 26 Apr 2020 18:14:53 GMT</pubDate>
            <atom:updated>2020-04-26T18:14:53.774Z</atom:updated>
            <content:encoded><![CDATA[<p>In this tutorial i will explain how you can use an <a href="https://en.wikipedia.org/wiki/Asynchronous_module_definition">AMD</a> based library in Visual Builder. If the library does not supports AMD style import, you should import the library directly in your <em>index.html</em>. Please read the library instructions before attempting to import it in Visual Builder.</p><h3>Configure requirejs paths</h3><p>Go to <em>app-flow.json</em> and make an entry like below</p><pre>&quot;requirejs&quot;:{<br>    &quot;paths&quot;:{<br>     &quot;xlsx&quot;:&quot;<a href="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.15.2/xlsx.full.min">https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.15.2/xlsx.full.min</a>&quot;</pre><pre>    }<br>  }</pre><p><em>requirejs</em> should be a sibling node to <em>id</em>, <em>description</em> or <em>defaultPage</em> entries in <em>app-flow.json</em>.</p><p>In the above step we are configure <em>requirejs</em> with a new path <em>xlsx </em>with the value <a href="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.15.2/xlsx.full.min">https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.15.2/xlsx.full.min</a> . <strong><em>Make sure you omit the .js at the end of the cdn url, requirejs will add it automatically. </em></strong>In case your lib is added as app resources i.e. available under <em>resources/js/</em><strong><em>path/to/lib</em></strong>. then your <em>requirejs</em> entry should look like this:</p><pre>&quot;requirejs&quot;:{<br>    &quot;paths&quot;:{<br>     &quot;myLib&quot;:&quot;resources/js/path/to/lib&quot;</pre><pre>}<br>  }</pre><p>Once configured, we can move to next step where we can consume the library.</p><h3>Import the library</h3><p>So far we have only configured from where we need to load our library, in this step we will load and use it.</p><p>In your page module define function, make an entry for the library</p><pre>define([&#39;xlsx&#39;], function(XLSX) {...}</pre><p>When the page is loaded <em>requirejs</em> will fetch the <em>xlsx</em> lib from the location defined in step#1 and pass down a reference to the callback function (<em>XLSX</em>). One thing you should know as a developer that all these are AMD specification for configuring and loading modules, visual builder uses requirejs (an AMD implementation) hence these step are needed.</p><p>Any module function you define in the page module will have access to the imported lib via XLSX.</p><h3>Version</h3><p><strong>VBCS: </strong>19.4.3.13</p><p><strong>JET: </strong>8.1.3</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cebc9a373378" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Create a countdown timer in React ⏱]]></title>
            <link>https://soomedh.medium.com/create-a-countdown-timer-in-react-327ed6255476?source=rss-aae72e81f01b------2</link>
            <guid isPermaLink="false">https://medium.com/p/327ed6255476</guid>
            <category><![CDATA[timer]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Sumedh Chakravorty]]></dc:creator>
            <pubDate>Sun, 26 Apr 2020 16:05:08 GMT</pubDate>
            <atom:updated>2020-04-26T16:05:08.685Z</atom:updated>
            <content:encoded><![CDATA[<p>We will be using functional component + hook for building this component. setInterval will be used for core timer.</p><h3>Create a component</h3><p>The code (kinda) looks like this. the timer (state) tracks the timer status. user can start/play or pause the timer.</p><pre>import React from &#39;react&#39;</pre><pre>function Timer() {</pre><pre>const [timer, setTimer] = React.useState({</pre><pre>name: &#39;&#39;,</pre><pre>isPaused: false,</pre><pre>time: 0,</pre><pre>timeRemaining: 0</pre><pre>})</pre><pre>const handleTimerCreate = e =&gt; {</pre><pre>}</pre><pre>return &lt;React.Fragment&gt;</pre><pre>&lt;input <em>type</em>=&quot;text&quot; <em>onChange</em>={handleTimerCreate} /&gt;</pre><pre>&lt;div&gt;</pre><pre>// render current timer details and actions</pre><pre>&lt;/div&gt;</pre><pre>&lt;/React.Fragment&gt;</pre><pre>}</pre><pre>export default Timer;</pre><h3>timer logic</h3><p>we are using browsers built-in setInterval for timer logic. we are also keeping track of the timerHandler.</p><pre>const handleStart = e =&gt; {</pre><pre>const handle = setInterval(updateTimeRemaining, 1000);</pre><pre>setTimer({ ...timer, isPaused: false, timerHandler: handle })</pre><pre>}</pre><p>we update the state with the interval handle, so that we can later clear it when it times out or it’s paused.</p><pre>const handlePause = e =&gt; {</pre><pre>clearInterval(timer.timerHandler)</pre><pre>setTimer({ ...timer, isPaused: true })</pre><pre>}</pre><h3>timer card and actions</h3><p>The timner card is visible when name and time is provided, when timeRemaining is 0 we add styles for timeout animations. the actions available on the timer are start/play and pause.</p><pre>{timer.name &amp;&amp; timer.time &amp;&amp;</pre><pre>&lt;div <em>className</em>={timer.timeRemaining === 0 ? &#39;time-out&#39;:&#39;&#39;} <em>style</em>={classes.card}&gt;</pre><pre>&lt;h3&gt;{timer.name}&lt;/h3&gt;</pre><pre>&lt;h2&gt;{timer.time}&lt;/h2&gt;</pre><pre>{timer.isPaused &amp;&amp; &lt;div <em>onClick</em>={handleStart}&gt;&lt;img <em>alt</em>=&quot;play&quot; <em>src</em>={play}/&gt;&lt;/div&gt;}</pre><pre>{!timer.isPaused &amp;&amp; &lt;div <em>onClick</em>={handlePause}&gt;&lt;img <em>alt</em>=&quot;pause&quot; <em>src</em>={pause}/&gt; &lt;/div&gt;}</pre><pre>&lt;h1&gt;{`Time remaining ${timer.timeRemaining}`}&lt;/h1&gt;</pre><pre>&lt;/div&gt;}</pre><h3>Action : start</h3><p>In the start/play action we are using setInterval with callback and timeout set to 1000ms. The callback handles the the updating of timeRemaining.</p><pre>const updateTimeRemaining = e =&gt; {</pre><pre>setTimer(prev =&gt; {</pre><pre>return { ...prev, timeRemaining: prev.timeRemaining - 1 }</pre><pre>})</pre><pre>}</pre><h3>Action : pause</h3><p>In pause handler, we are clearning the timerHandler and setting the timer as paused.</p><pre>const handlePause = e =&gt; {</pre><pre>clearInterval(timer.timerHandler)</pre><pre>setTimer({ ...timer, isPaused: true })</pre><pre>}</pre><h3>Handle timeout</h3><p>We are using useEffect hook for tracking timeRemaining and updating timer state based on timeRemaining.</p><pre>React.useEffect(() =&gt; {</pre><pre>if (timer.timeRemaining === 0) {</pre><pre>clearInterval(timer.timerHandler)</pre><pre>}</pre><pre>}, [timer.timeRemaining, timer.timerHandler])</pre><h3>The final component</h3><pre>import React from &#39;react&#39;;</pre><pre>import &#39;./App.css&#39;;</pre><pre>import pause from &#39;./pause.svg&#39;</pre><pre>import play from &#39;./play.svg&#39;</pre><pre>const classes = {</pre><pre>card: {</pre><pre>height: &#39;20em&#39;,</pre><pre>width: &#39;10em&#39;,</pre><pre>border: &#39;1px solid #5353ca&#39;,</pre><pre>borderRadius: &#39;10px&#39;,</pre><pre>backgroundColor: &#39;#5353ca&#39;,</pre><pre>margin: &#39;auto&#39;,</pre><pre>marginTop: &#39;5em&#39;,</pre><pre>color: &#39;white&#39;,</pre><pre>padding: &#39;10px&#39;,</pre><pre>boxShadow:&#39;-1px 1px 7px 3px #0000003d &#39;</pre><pre>}</pre><pre>}</pre><pre>function Timer() {</pre><pre>const [timer, setTimer] = React.useState({</pre><pre>name: &#39;ee&#39;,</pre><pre>isPaused: true,</pre><pre>time: 100,</pre><pre>timeRemaining: 100,</pre><pre>timerHandler: null</pre><pre>})</pre><pre>const handleTimerCreate = e =&gt; {</pre><pre>setTimer({</pre><pre>...timer,</pre><pre>name: e.target.value</pre><pre>})</pre><pre>}</pre><pre>const handleTimeChange = e =&gt; {</pre><pre>setTimer({</pre><pre>...timer,</pre><pre>time: Number(e.target.value),</pre><pre>timeRemaining: Number(e.target.value),</pre><pre>})</pre><pre>}</pre><pre>React.useEffect(() =&gt; {</pre><pre>if (timer.timeRemaining === 0) {</pre><pre>clearInterval(timer.timerHandler)</pre><pre>}</pre><pre>}, [timer.timeRemaining, timer.timerHandler])</pre><pre>const updateTimeRemaining = e =&gt; {</pre><pre>setTimer(prev =&gt; {</pre><pre>return { ...prev, timeRemaining: prev.timeRemaining - 1 }</pre><pre>})</pre><pre>}</pre><pre>const handleStart = e =&gt; {</pre><pre>const handle = setInterval(updateTimeRemaining, 1000);</pre><pre>setTimer({ ...timer, isPaused: false, timerHandler: handle })</pre><pre>}</pre><pre>const handlePause = e =&gt; {</pre><pre>clearInterval(timer.timerHandler)</pre><pre>setTimer({ ...timer, isPaused: true })</pre><pre>}</pre><pre>return &lt;React.Fragment&gt;</pre><pre>&lt;input <em>value</em>={timer.name} <em>type</em>=&quot;text&quot; <em>onChange</em>={handleTimerCreate} /&gt;</pre><pre>&lt;input <em>value</em>={timer.time} <em>type</em>=&quot;number&quot; <em>onChange</em>={handleTimeChange} /&gt;</pre><pre>{timer.name &amp;&amp; timer.time &amp;&amp; &lt;div <em>className</em>={timer.timeRemaining === 0 ? &#39;time-out&#39;:&#39;&#39;} <em>style</em>={classes.card}&gt;</pre><pre>&lt;h3&gt;{timer.name}&lt;/h3&gt;</pre><pre>&lt;h2&gt;{timer.time}&lt;/h2&gt;</pre><pre>{timer.isPaused &amp;&amp; &lt;div <em>onClick</em>={handleStart}&gt;&lt;img <em>alt</em>=&quot;play&quot; <em>src</em>={play}/&gt;&lt;/div&gt;}</pre><pre>{!timer.isPaused &amp;&amp; &lt;div <em>onClick</em>={handlePause}&gt;&lt;img <em>alt</em>=&quot;pause&quot; <em>src</em>={pause}/&gt; &lt;/div&gt;}</pre><pre>&lt;h1&gt;{`Time remaining ${timer.timeRemaining}`}&lt;/h1&gt;</pre><pre>&lt;/div&gt;}</pre><pre>&lt;/React.Fragment&gt;</pre><pre>}</pre><h3>styles</h3><pre>.time-out {</pre><pre>animation: shake 0.92s cubic-bezier(.36,.07,.19,.97) infinite;</pre><pre>transform: translate3d(0, 0, 0);</pre><pre>backface-visibility: hidden;</pre><pre>perspective: 1000px;</pre><pre>}</pre><pre>@keyframes shake {</pre><pre>10%, 90% {</pre><pre>transform: translate3d(-1px, 0, 0);</pre><pre>}</pre><pre>20%, 80% {</pre><pre>transform: translate3d(2px, 0, 0);</pre><pre>}</pre><pre>30%, 50%, 70% {</pre><pre>transform: translate3d(-4px, 0, 0);</pre><pre>}</pre><pre>40%, 60% {</pre><pre>transform: translate3d(4px, 0, 0);</pre><pre>}</pre><pre>}</pre><p><em>Originally published at </em><a href="https://sumedh.netlify.com/react/timer-component/"><em>https://sumedh.netlify.app</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=327ed6255476" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[React load more on scroll]]></title>
            <link>https://soomedh.medium.com/react-load-more-on-scroll-acac95e47ae?source=rss-aae72e81f01b------2</link>
            <guid isPermaLink="false">https://medium.com/p/acac95e47ae</guid>
            <category><![CDATA[pagination]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[material-design]]></category>
            <dc:creator><![CDATA[Sumedh Chakravorty]]></dc:creator>
            <pubDate>Thu, 06 Feb 2020 07:00:13 GMT</pubDate>
            <atom:updated>2020-02-29T19:48:29.850Z</atom:updated>
            <content:encoded><![CDATA[<h3>React Infinite scroll</h3><p>Load data progressively as user scrolls down with minimal coding. Skip to the <em>The Front End</em> section if you already have a backend available. Both backend and front end code is available on <a href="https://github.com/sumedh22/react-load-more-on-scroll/">GitHub</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/990/1*itMcLR1_dQy-9-HLwYwWSQ.gif" /><figcaption>load more on scroll</figcaption></figure><h3>The Backend</h3><p>For this demo we need a backend which is capable of handling paging controls. we are using spring boot with the following dependencies:</p><ol><li><strong>spring-boot-starter-data-rest</strong> : Exposes repositories as Rest Endpoints</li><li><strong>spring-boot-starter-data-jpa</strong> : For creating repositories</li><li><strong>h2</strong> : embedded database for quick start</li></ol><h4>Configuring Entity</h4><p>For the demo we are using a standard Employee entity</p><pre>@Entity<br> class Employee {<br><br>   @Id<br>   @GeneratedValue(strategy = GenerationType.<em>AUTO</em>)<br>   private long id;<br>   private String firstName;<br>   private String lastName;<br>   private String gender;<br>   private String ipAddress;<br>   private String email;</pre><pre>... getters and setters</pre><pre>}</pre><h4>Configuring Rest Repository</h4><p>Extending the <strong><em>PagingAndSortingRepository </em></strong>to expose the Employee entity.</p><pre>@RepositoryRestResource(collectionResourceRel = &quot;employee&quot;, path = &quot;employee&quot;)<br> interface EmployeeRepository extends PagingAndSortingRepository&lt;Employee, Long&gt; {<br>   List&lt;Employee&gt; findByFirstName(@Param(&quot;firstName&quot;) String name);<br>}</pre><h4>Configuring CORS</h4><p>Extending <strong><em>RepositoryRestConfigurer</em></strong> and overriding <strong><em>configureRepositoryRestConfiguration</em></strong> method to configure cross origin domains.</p><pre>@Configuration<br> class ConfigRepositoryRest implements RepositoryRestConfigurer {<br>   @Override<br>   public void configureRepositoryRestConfiguration(RepositoryRestConfiguration config) {<br>      config.getCorsRegistry()<br>            .addMapping(&quot;/**&quot;)<br>            .allowedOrigins(&quot;http://localhost:3000&quot;);<br>   }<br>}</pre><h3>The Front End : React App</h3><p>For pagination support we are using <a href="https://www.npmjs.com/package/react-hook-pagination"><strong><em>react-hook-pagination</em></strong></a><strong><em> </em></strong>library and for UI elements we are using <a href="https://www.npmjs.com/package/@material-ui/core"><strong><em>@material-ui/core</em></strong></a></p><h4>Simple list — without pagination</h4><p>We are using material components to create a <a href="https://material-ui.com/components/lists/">list</a>. The list data is stored as one of the state property of the component and for iterating over the data we are using <a href="https://www.npmjs.com/package/react-for-loop">For</a> component.</p><pre>&lt;<strong>List</strong> ref={scroller}&gt;</pre><pre>&lt;For data={<strong>data</strong>} itemRenderer={(emp, idx) =&gt; (</pre><pre>  &lt;ListItem key={idx} button&gt;</pre><pre>  &lt;ListItemIcon&gt;</pre><pre>    &lt;Avatar&gt;{getInitials(emp.firstName, emp.lastName)}&lt;/Avatar&gt;</pre><pre>  &lt;/ListItemIcon&gt;</pre><pre>  &lt;ListItemText primary={`${emp.firstName} ${emp.lastName}`}&gt;     &lt;/ListItemText&gt;</pre><pre>&lt;/ListItem&gt;)}</pre><pre>&gt;&lt;/For&gt;<br>&lt;/<strong>List</strong>&gt;</pre><p>Defining the data, initialising with empty array.</p><pre>const [data, setData] = useState([]);</pre><h4>list — with pagination</h4><p>In order to add pagination to the above list we need to import the below libs:</p><pre>import React, { <strong>useRef</strong>, useState, <strong>useEffect</strong> } from &quot;react&quot;;<br>import <strong>useLoadMoreOnScroll</strong> from &quot;react-hook-pagination&quot;;</pre><p>Initialising <strong>useLoadMoreOnScroll </strong>involves specifying 3 params: <em>fetchSize</em>: size of each chunk of data as we fetch progressively , <em>scroller</em>: the scroll container whose scroll position will be monitored , <em>limit</em>: max. items to be displayed in the list.</p><pre>const scroller = useRef();</pre><pre>const {</pre><pre>  start,</pre><pre>  end,</pre><pre>  isFetching,</pre><pre>  doneFetching,</pre><pre>  setIsFetching,</pre><pre>  forceDonefetching</pre><pre>} = useLoadMoreOnScroll({ fetchSize: 20, scroller: scroller, limit: 1000 });</pre><p>The <strong>useLoadMoreOnScroll </strong>hook returns the start , end etc letting the component know when it should fetch the next batch. Boolean attributes like isFetching, doneFetching can be used to display messages or loaders. The scroller in our demo is the List itself.</p><pre>&lt;List ref={scroller}&gt;<br>...<br>&lt;/List&gt;</pre><p>Based on the scroll position the hook will update the new set of start and end indices and our component and react to that effect by fetching the new batch of data. This could be implemented by using the react <strong>useEffect</strong> hook.</p><pre>useEffect(() =&gt; {</pre><pre>  if (start !== end) {</pre><pre>  setIsFetching(true);</pre><pre>  fetchEmployees(start, end).then(employees =&gt; {</pre><pre>    setData([...data, ...employees]);</pre><pre>    setIsFetching(false);</pre><pre>  });</pre><pre>}</pre><pre>}, [start, end]);</pre><p>We are using <strong>setIsFetching </strong>to let the hook know that the next batch of data is currently being fetched hence it should not ask for next set. Once we receive the data from the service, we are updating our state (data, using setData).</p><p><strong>fetchEmployees </strong>does the actual fetching based on the specified start and end indices.</p><pre>const fetchEmployees = async (start, end) =&gt; {</pre><pre>  const size = end - start;</pre><pre>  const page = end / size;</pre><pre>  const response = await fetch(</pre><pre>  `http://localhost:8080/employee?size=${size}&amp;page=${page}`</pre><pre>  );</pre><pre>  const res = await response.json();</pre><pre>  if (res.page.totalPages &lt;= page) {</pre><pre>    forceDonefetching();</pre><pre>  }</pre><pre>  return res._embedded.employee;</pre><pre>};</pre><p>Our backend expects size and page parameters which we are deriving from the passed indices. Once we are done fetching all the data we are calling <strong>forceDonefetching </strong>to let the hook know we should not fetch anymore.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=acac95e47ae" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>