<?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 Jeevan Kishore on Medium]]></title>
        <description><![CDATA[Stories by Jeevan Kishore on Medium]]></description>
        <link>https://medium.com/@kishor080?source=rss-a87ea2a25742------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*-XiMBZxrcNjaPiUO.</url>
            <title>Stories by Jeevan Kishore on Medium</title>
            <link>https://medium.com/@kishor080?source=rss-a87ea2a25742------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 02:27:03 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@kishor080/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[Customised payment UPI QR code generation]]></title>
            <link>https://medium.com/@kishor080/customised-payment-upi-qr-code-generation-b878e03debb0?source=rss-a87ea2a25742------2</link>
            <guid isPermaLink="false">https://medium.com/p/b878e03debb0</guid>
            <category><![CDATA[nextjs]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[qr-code]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[productivity]]></category>
            <dc:creator><![CDATA[Jeevan Kishore]]></dc:creator>
            <pubDate>Sat, 30 Jul 2022 07:17:00 GMT</pubDate>
            <atom:updated>2022-08-03T04:55:06.781Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*mBSUof8rxLk4NQr8.png" /></figure><h3>Use case</h3><figure><img alt="partying" src="https://cdn-images-1.medium.com/max/973/1*n9eQeQDag3_EsCVkcXaSGA.png" /></figure><p>Recently i had been to a party, paid the bill amount and had to split the cheque with several people.</p><p>Communicating on how much.. where to transfer, which app to use and what not.. was a pain!</p><p>— Instead —</p><p>Show a QR which works on all apps, scan -&gt; get paid -&gt; done</p><h3>Generator</h3><figure><img alt="live demo" src="https://cdn-images-1.medium.com/max/600/1*bOS6_6YrF_NgZe1L1aDUaA.gif" /></figure><p>Live demo: <a href="https://upi-qr.vercel.app/">https://upi-qr.vercel.app/</a><br> Source code: <a href="https://github.com/Jeevan-Kishore/upi-qr-generator">https://github.com/Jeevan-Kishore/upi-qr-generator</a></p><h3>Architecture</h3><ul><li>Call the API on click of generateQR with the above mentioned format</li><li>Serverless function creates a QR using the details set via a GET call /api/getqr/[name]/[upi]/[amount]</li><li>A deelinking URL is constructed, out of which a QR is generated</li><li>API responds back with a .png - dataURI</li><li>Canvas of 300x300 is constructed to which received dataURI is set as src</li></ul><p>QR generation has a variety of usecase(s), this is just one of them we thought to share.</p><p>Cheers 🍺</p><p><em>Originally published at </em><a href="https://dev.to/jeevankishore/upi-qr-code-generation-4k8a"><em>https://dev.to</em></a><em> on July 30, 2022.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b878e03debb0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Run android emulator on CircleCI]]></title>
            <link>https://medium.com/@kishor080/run-android-emulator-on-circleci-3aad1a7c0ef5?source=rss-a87ea2a25742------2</link>
            <guid isPermaLink="false">https://medium.com/p/3aad1a7c0ef5</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[circleci]]></category>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[Jeevan Kishore]]></dc:creator>
            <pubDate>Sat, 26 Sep 2020 06:49:33 GMT</pubDate>
            <atom:updated>2020-09-26T06:49:33.478Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ddQA5HMPpnl4MOv3" /></figure><p>Running an android emulator on a CI such as CircleCI has been a challenge for a lot of people who want to automate their test cases due to the fact that android emulator require hardware acceleration which is unavailable on debian terminals</p><p>We managed to get a headless emulator running on CircleCI with their iOS terminals.</p><p>iOS terminals need to be set up to accommodate the emulators, they have dependencies such as SDK’s, NDK’s, platform tools,</p><p>We would have to do the following:</p><ul><li>Configure ANDROID_SDK_ROOT</li><li>Download SDK Tools and unzip</li><li>Create license directory and agree to all licenses</li><li>Set SDKManager path</li><li>Install the following</li><li>“platform-tools”</li><li>“platforms;android-29”</li><li>“build-tools;29.0.2”</li><li>“ndk-bundle”</li><li>“system-images;android-29;google_apis;x86_64”</li><li>“emulator”</li></ul><p>Let’s create a sh to do that</p><blockquote><em>scripts/install-android-tools.sh</em></blockquote><pre>if [ -d $ANDROID_SDK_ROOT ]<br>then<br>    echo &quot;Directory $ANDROID_SDK_ROOT already exists so we&#39;re skipping the install. If you&#39;d like to install fresh tools, edit this script to invalidate the CI cache.&quot;<br>    exit 0<br>fi<br><br>mkdir -p $ANDROID_SDK_ROOT<br>cd $ANDROID_SDK_ROOT<br>curl https://dl.google.com/android/repository/sdk-tools-darwin-4333796.zip -o sdk-tools.zip<br><br>unzip sdk-tools.zip<br><br>mkdir -p &quot;$ANDROID_SDK_ROOT/licenses&quot;<br><br>echo &quot;24333f8a63b6825ea9c5514f83c2829b004d1fee&quot; &gt; &quot;$ANDROID_SDK_ROOT/licenses/android-sdk-license&quot;<br>echo &quot;84831b9409646a918e30573bab4c9c91346d8abd&quot; &gt; &quot;$ANDROID_SDK_ROOT/licenses/android-sdk-preview-license&quot;<br>echo &quot;d975f751698a77b662f1254ddbeed3901e976f5a&quot; &gt; &quot;$ANDROID_SDK_ROOT/licenses/intel-android-extra-license&quot;<br><br>SDKMANAGER=$ANDROID_SDK_ROOT/tools/bin/sdkmanager<br><br>$SDKMANAGER &quot;platform-tools&quot;<br>$SDKMANAGER &quot;platforms;android-29&quot;<br>$SDKMANAGER &quot;build-tools;29.0.2&quot;<br>$SDKMANAGER &quot;ndk-bundle&quot;<br>$SDKMANAGER &quot;system-images;android-29;google_apis;x86_64&quot;<br>$SDKMANAGER &quot;emulator&quot;<br><br>echo &quot;y&quot; | sudo $SDKMANAGER --install &quot;ndk;20.0.5594570&quot; --sdk_root=${ANDROID_SDK_ROOT}</pre><p>Let’s write a command block on circle ci to set path, run scripts and cache</p><pre>android-sdk-dependencies:<br>    description: &quot;Install and set android SDK&quot;<br>    steps:<br>      - run:<br>          name: set ANDROID_SDK_ROOT<br>          command: |<br>            echo &#39;export ANDROID_SDK_ROOT=$HOME/android-tools&#39;  &gt;&gt; $BASH_ENV<br>      - restore_cache:<br>          key: android=tools-v1-{{ checksum &quot;scripts/install-android-tools.sh&quot; }}-{{ arch }}<br><br>      - run:<br>          name: install android tools<br>          command: |<br>            sh scripts/install-android-tools.sh<br>            echo &#39;export PATH=$ANDROID_SDK_ROOT/tools/bin:$PATH&#39;  &gt;&gt; $BASH_ENV<br>            echo &#39;export PATH=$ANDROID_SDK_ROOT/tools:$PATH&#39;  &gt;&gt; $BASH_ENV<br>            echo &#39;export PATH=$ANDROID_SDK_ROOT/platform-tools:$PATH&#39;  &gt;&gt; $BASH_ENV<br>            echo &#39;export PATH=$ANDROID_SDK_ROOT/emulator:$PATH&#39;  &gt;&gt; $BASH_ENV<br>            source $BASH_ENV<br>            sdkmanager --list<br>      - save_cache:<br>          key: android=tools-v1-{{ checksum &quot;scripts/install-android-tools.sh&quot; }}-{{ arch }}<br>          paths:<br>            - /Users/distiller/android-tools</pre><p>All that’s left to do now, is to create the emulator and boot it up as a background job</p><pre>create-launch-android-emulator:<br>    description: &quot;create and launch android emulators&quot;<br>    steps:<br>      - run:<br>          name: create AVD<br>          command: echo &quot;no&quot; | avdmanager --verbose create avd --force --name &quot;Pixel_3a_API_29&quot; --package &quot;system-images;android-29;google_apis;x86_64&quot;<br><br>      - run:<br>          name: start AVD<br>          command: emulator @Pixel_3a_API_29 -no-window -no-audio<br>          background: true<br><br>      - run:<br>          name: wait for emulator<br>          command: adb wait-for-device shell &#39;while [[ -z $(getprop dev.bootcomplete) ]]; do sleep 1; done;&#39;</pre><p>Your emulator is now up and running on CCI, <a href="https://github.com/Jeevan-Kishore/e2e-detox/blob/master/.circleci/config.yml">here</a> is the link for the complete configuration of CircleCI</p><p>If you have questions, let us know in the comments and we are looking forward for your feedback 🍻</p><p><em>Originally published at </em><a href="https://resolvedpromise.hashnode.dev/run-android-emulator-on-circleci"><em>https://resolvedpromise.hashnode.dev</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3aad1a7c0ef5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Memory leak by anonymous functions]]></title>
            <link>https://medium.com/@kishor080/memory-leak-by-anonymous-functions-49428bf0152c?source=rss-a87ea2a25742------2</link>
            <guid isPermaLink="false">https://medium.com/p/49428bf0152c</guid>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Jeevan Kishore]]></dc:creator>
            <pubDate>Sat, 30 May 2020 21:40:21 GMT</pubDate>
            <atom:updated>2020-05-30T21:56:13.564Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*6wu9RQjSFgdGWr-GPEku2Q.gif" /><figcaption>some spinach helps fix that leak</figcaption></figure><p>With introduction of fat arrow functions ➕ the implicit bind magic, JS developers found an everlasting 💛 towards them.</p><p>Although they were eye pleasing and a delight, they bought with a variety of concerns if not implemented wisely.</p><p>One such case i found myself having numerous conversations with my peers about; is having anonymous functions to handle the events which developers find easy to use and miss the subtle ugly memory leak they cause.</p><p><em>P.S This article won’t be dwelling to the 🐘 depths of memory leak identification and resolutions but to emphasis on the fact that taking the easy route in this case will end up hitting the hardest.</em></p><h3>✨ Theory</h3><p>An anonymous function might not be cleared by GC (garbage collection) efficiently during a mark and sweep phase as the references to it cannot be determined hence GC fails to recover back the allocated memory</p><h3>✨ Lab setup</h3><ul><li>Production react build running on chrome</li><li>Run about 10k state changes on each scenario of with and without anonymous implementation to trigger re-renders</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UNokg3zxsoiiVYEmhxgt4w.png" /><figcaption>preview of workspace</figcaption></figure><h3>✨ Analysis</h3><p>That being said, let’s jump on to the crux and look at some stats;</p><p>Recording a snapshot of each implementation clearly depicts a memory leak with the anonymous function implementation</p><p>Snapshot <strong>without</strong> anonymous functions</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/0*5IP26PuFr1V4dRKp.png" /></figure><p>🔸<a href="https://i.ibb.co/0F1ZHKf/Screenshot-2020-05-30-at-4-19-43-PM.png"><em>fig (i)</em></a></p><p>Snapshot <strong>with</strong> anonymous functions</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/0*OBIero4QNMofdmKW.png" /></figure><p>🔸<a href="https://i.ibb.co/zfwdKWW/Screenshot-2020-05-30-at-4-21-17-PM.png"><em>fig (ii)</em></a></p><p>As we compare fig (i) with fig (ii) it’s clear that the memory allocation has been freed up by GC in fig (i) as opposed to that of fig(ii)</p><p>The <em>exaggerated</em> example intends to portrays the memory leak with the approach; which holds true for apps of multiple complexities in the real world</p><h3>✨ Conclusion =&gt;</h3><p>Anonymous fat arrow functions within render methods pave way for a memory leak and ipso facto an <em>anti-pattern</em></p><h3>✨ Show me the code</h3><p><a href="https://github.com/Jeevan-Kishore/space-complexity">Jeevan-Kishore/space-complexity</a></p><p>If you have questions, let us know in the comments and we are looking forward for your feedback 🍻</p><p><em>Originally published at </em><a href="https://dev.to/jeevankishore/memory-leak-by-anonymous-functions-77p"><em>https://dev.to</em></a><em> on May 30, 2020.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=49428bf0152c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Build infinite pagination with ES6 async generators and iterables]]></title>
            <link>https://levelup.gitconnected.com/build-infinite-pagination-with-es6-async-generators-and-iterables-f29a46aac466?source=rss-a87ea2a25742------2</link>
            <guid isPermaLink="false">https://medium.com/p/f29a46aac466</guid>
            <category><![CDATA[beginner]]></category>
            <category><![CDATA[es6]]></category>
            <category><![CDATA[beginners-guide]]></category>
            <category><![CDATA[pagination]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Jeevan Kishore]]></dc:creator>
            <pubDate>Thu, 07 May 2020 04:20:17 GMT</pubDate>
            <atom:updated>2020-09-29T20:37:00.737Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*DNDuE_yuHcCi8-Jc.gif" /></figure><h3>What the 🐠 is a generator?</h3><p>Well, according to the definition :</p><blockquote><em>Generators are functions which can be exited and later re-entered. Their context (variable bindings) will be saved across re-entrances.</em></blockquote><h3>Fancy, what does this bring to the table? 💭</h3><p>argh, definition again.. 💤</p><blockquote><em>Generators in JavaScript — especially when combined with Promises — are a very powerful tool for asynchronous programming</em></blockquote><h3>A real world scenario?</h3><p>After all that definition reading, let’s jump into the core of it. :octocat:</p><p>We had an interesting problem on our hands to tackle. It was to enable pagination to one of our mobile app’s on swipe right.</p><h3>So we use generators for it?</h3><p>There are other possible solutions, generators are just a cleaner solution.</p><h3>How to do it?</h3><p>&gt; Create a generator</p><pre>const asyncGetContent = async function* (){<br>  const limit = 10; /* content per page */<br>  let offset = 0; /* index of item to start from */<br>  let totalCount = -1; /* -1 signifies failure */<br>  while (offset === 0 || offset &lt; totalCount) {<br>    try {<br>      const response = await (await fetch(&lt;&lt;url&gt;&gt;)).json();<br>      offset = offset + limit;<br>      totalCount = response[&quot;total-count&quot;];<br>      console.log(`offset + totalCount`, offset, totalCount);<br>      yield response;<br>    } catch (e) {<br>      console.warn(`exception during fetch`, e);<br>      yield {<br>        done: true,<br>        value: &quot;error&quot;<br>      };<br>    }<br>  }<br><br>}</pre><p>That’s a lot to understand, let’s go through each line.</p><p>⛄ we’ve limit which defines a variable to set the limit on the results of your choice [need not be a constant]</p><p>⛄ prepare a fetch/ axios/ some API call, shoot it with an await such that we will resolve the resulting promise.</p><p>⛄ yield the response. The return will be a promise to be consumed by the async caller using .next()(we&#39;ll get to that in the next section)</p><p>⛄ let’s just handle fetch</p><blockquote><em>How do i use this?</em></blockquote><pre>const contentGen = await asyncGetContent(); /* initate the generator */</pre><p>All that’s left to do is to initiate and call it within an async function as such:</p><p>after initiation, we can call wherever required (ex: right swipe / click of a button) to yield the result</p><pre>const content = await contentGen.next();</pre><p>use content [the response from the api in this case] as necessary</p><p>If you have questions, let us know in the comments and we are looking forward for your feedback 🍻</p><p><em>Originally published at </em><a href="https://dev.to/jeevankishore/build-pagination-with-es6-async-generators-and-iterables-4l4p"><em>https://dev.to</em></a><em> on May 7, 2020.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f29a46aac466" width="1" height="1" alt=""><hr><p><a href="https://levelup.gitconnected.com/build-infinite-pagination-with-es6-async-generators-and-iterables-f29a46aac466">Build infinite pagination with ES6 async generators and iterables</a> was originally published in <a href="https://levelup.gitconnected.com/">Level Up Coding</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[End to End Testing with Detox on React-Native]]></title>
            <link>https://medium.com/@kishor080/end-to-end-testing-with-detox-on-react-native-8a0db5bf4a83?source=rss-a87ea2a25742------2</link>
            <guid isPermaLink="false">https://medium.com/p/8a0db5bf4a83</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[detox]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Jeevan Kishore]]></dc:creator>
            <pubDate>Tue, 05 May 2020 05:47:23 GMT</pubDate>
            <atom:updated>2020-05-05T05:47:23.423Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*vdnzb2KZLDBIpB9v" /><figcaption>Photo by <a href="https://unsplash.com/@christinhumephoto?utm_source=medium&amp;utm_medium=referral">Christin Hume</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Assumptions</h3><p>Before we begin, this article assumes RN (expo or otherwise) is set up on your terminal and your app is up and running.</p><p>If not please see <a href="https://reactnative.dev/docs/environment-setup">how</a> to do that.</p><p>We will be proceeding with a setup built using React Native CLI.</p><p>P.S Either will do.</p><p>Our app is called a (it&#39;s weird. I know.)</p><h3>Why Detox?</h3><p>What does detox offer over others? I’ll let their own <a href="https://github.com/wix/Detox#about">page</a> talk about it</p><h3>🔰 Phase 1 — Setting up detox</h3><p>By this time, your RN app should be up and running on a mac machine. Let’s proceed setting up Detox.</p><h4>Installing packages:</h4><p>Install the following packages using your terminal,</p><pre>xcode-select --install<br>    brew update &amp;&amp; brew install node<br>    brew tap wix/brew<br>    brew install applesimutils<br>    npm install -g detox-cli<br>    npm install detox --save-dev</pre><p>If jest is not already installed in your project,</p><pre>npm install jest --save-dev</pre><p>Use this command for detox to generate a jest scaffolding,</p><pre>detox init -r jest</pre><p>It will create a bunch of files under e2e directory with preset configurations.</p><h4>Add detox configuration:</h4><p>The following configuration needs to be added in package.json of the project,</p><p><em>package.json</em></p><pre>&quot;detox&quot;: {<br>    &quot;configurations&quot;: {<br>      &quot;android.emu.debug&quot;: {<br>        &quot;binaryPath&quot;: &quot;android/app/build/outputs/apk/debug/app-debug.apk&quot;,<br>        &quot;build&quot;: &quot;cd android &amp;&amp; ./gradlew app:assembleDebug assembleAndroidTest -DtestBuildType=debug &amp;&amp; cd ..&quot;,<br>        &quot;type&quot;: &quot;android.emulator&quot;,<br>        &quot;device&quot;: {<br>          &quot;avdName&quot;: &quot;detoxTestEmulator&quot;<br>        }<br>      },<br>      &quot;android.emu.release&quot;: {<br>        &quot;binaryPath&quot;: &quot;android/app/build/outputs/apk/release/app-release.apk&quot;,<br>        &quot;build&quot;: &quot;cd android &amp;&amp; ./gradlew app:assembleRelease assembleAndroidTest -DtestBuildType=release &amp;&amp; cd ..&quot;,<br>        &quot;type&quot;: &quot;android.emulator&quot;,<br>        &quot;device&quot;: {<br>          &quot;avdName&quot;: &quot;detoxTestEmulator&quot;<br>        }<br>      },<br>      &quot;ios.sim.release&quot;: {<br>        &quot;binaryPath&quot;: &quot;ios/build/Build/Products/Release-iphonesimulator/a.app&quot;,<br>        &quot;build&quot;: &quot;export RCT_NO_LAUNCH_PACKAGER=true &amp;&amp; xcodebuild -workspace ios/a.xcworkspace -scheme a -configuration Release -sdk iphonesimulator -derivedDataPath ios/build&quot;,<br>        &quot;type&quot;: &quot;ios.simulator&quot;,<br>        &quot;device&quot;: {<br>          &quot;type&quot;: &quot;iPhone 11 Pro&quot;<br>        }<br>      },<br>      &quot;ios.sim.debug&quot;: {<br>        &quot;binaryPath&quot;: &quot;ios/build/Build/Products/Debug-iphonesimulator/a.app&quot;,<br>        &quot;build&quot;: &quot;xcodebuild -workspace ios/a.xcworkspace  -scheme a -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build&quot;,<br>        &quot;type&quot;: &quot;ios.simulator&quot;,<br>        &quot;device&quot;: {<br>          &quot;type&quot;: &quot;iPhone 11 Pro&quot;<br>        }<br>      }<br>    },<br>    &quot;test-runner&quot;: &quot;jest&quot;<br>  }</pre><h4>What’s happening through the configuration? 😅</h4><p>Let’s walk through.</p><p><em>android</em></p><pre>&quot;android.emu.release&quot;: {<br>        &quot;binaryPath&quot;: &quot;android/app/build/outputs/apk/release/app-release.apk&quot;,<br>        &quot;build&quot;: &quot;cd android &amp;&amp; ./gradlew app:assembleRelease assembleAndroidTest -DtestBuildType=release &amp;&amp; cd ..&quot;,<br>        &quot;type&quot;: &quot;android.emulator&quot;,<br>        &quot;device&quot;: {<br>          &quot;avdName&quot;: &quot;detoxTestEmulator&quot;<br>        }<br>      }</pre><p>The android release configuration consists of :</p><ul><li>holds path to the built apk to test</li><li>build commands with build type</li><li>type and name of the emulator (this name should be the same as the emulator which should be created using android studio)</li></ul><p>Note: On how to create emulators, <a href="https://developer.android.com/studio/run/managing-avds">here</a> is a doc which details it.</p><p><em>ios</em></p><pre>&quot;ios.sim.release&quot;: {<br>        &quot;binaryPath&quot;: &quot;ios/build/Build/Products/Release-iphonesimulator/a.app&quot;,<br>        &quot;build&quot;: &quot;export RCT_NO_LAUNCH_PACKAGER=true &amp;&amp; xcodebuild -workspace ios/a.xcworkspace -scheme a -configuration Release -sdk iphonesimulator -derivedDataPath ios/build&quot;,<br>        &quot;type&quot;: &quot;ios.simulator&quot;,<br>        &quot;device&quot;: {<br>          &quot;type&quot;: &quot;iPhone 11 Pro&quot;<br>        }<br>      }</pre><p>The android release configuration consists of :</p><ul><li>path to built binary (a is the name of our app hence it&#39;s a.app, it would be [app_name].app)</li><li>build commands with scheme and path to workspace as per the name of the app (ios/[app_name].xcworkspace)</li><li>type and device the tests are to run on</li></ul><p>With the detox configuration in place, iOS is all set to be worked with. 🎉</p><p>Android on the other hand, well.. “ Needs a lot more work. “ ⛄</p><h4>Setup detox with android:</h4><p>📃 <em>android/app/build.gradle</em></p><p>Add the following lines to default section</p><pre>testBuildType System.getProperty(&#39;testBuildType&#39;, &#39;debug&#39;)  &#39;androidx.test.runner.AndroidJUnitRunner&#39;</pre><p>Add the following lines to dependencies section</p><pre>androidTestImplementation(&#39;com.wix:detox:+&#39;) { transitive = true }<br>androidTestImplementation &#39;junit:junit:4.12&#39;</pre><p>📃 <em>android/app/src/androidTest/java/com/a/DetoxTest.java</em></p><pre>package com.a; /* change to app package name */</pre><pre>    import com.wix.detox.Detox;</pre><pre>    import org.junit.Rule;<br>    import org.junit.Test;<br>    import org.junit.runner.RunWith;</pre><pre>    import androidx.test.ext.junit.runners.AndroidJUnit4;<br>    import androidx.test.filters.LargeTest;<br>    import androidx.test.rule.ActivityTestRule;</pre><pre>    @RunWith(AndroidJUnit4.class)<br>    @LargeTest<br>    public class DetoxTest {</pre><pre>        @Rule<br>        public ActivityTestRule&lt;MainActivity&gt; mActivityRule = new ActivityTestRule&lt;&gt;(MainActivity.class, false, false);</pre><pre>        @Test<br>        public void runDetoxTests() {<br>            Detox.runTests(mActivityRule);<br>        }<br>    }</pre><p>The above file should be created as per the hierarchical order android/app/src/androidTest/java/com/[app_name]/DetoxTest.java</p><p>📃 <em>android/app/src/main/AndroidManifest.xml</em></p><p>The snippet should be added to the &lt;application tag, this is required for detox to perform as expected (<a href="https://developer.android.com/guide/topics/manifest/application-element">what is this?</a>)</p><pre>android:usesCleartextTraffic=&quot;true&quot;</pre><p>📃 <em>android/build.gradle</em></p><p>Change minSdkVersion to 18 or higher, add kotlinVersion if it&#39;s not already present under ext.</p><p>It should look similar to this,</p><pre>ext {<br>        buildToolsVersion = &quot;28.0.3&quot;<br>        minSdkVersion = 18<br>        compileSdkVersion = 28<br>        targetSdkVersion = 28<br>        kotlinVersion = &quot;1.3.61&quot;<br>    }</pre><p>Add classpath &quot;org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion&quot; under dependencies</p><pre>dependencies {<br>            // ...<br>            classpath &quot;org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion&quot;<br>        }</pre><p>Add the following maven snippet under repositories</p><pre>allprojects {<br>        repositories {<br>                // ... statements<br>            maven {<br>                // All of Detox&#39; artifacts are provided via the npm module<br>                url &quot;$rootDir/../node_modules/detox/Detox-android&quot;<br>            }<br>        }<br>    }</pre><p>With the above steps done, android is all set to go. 🎉</p><p>⚠️ To verify if this are going good, cross check with this <a href="https://github.com/Jeevan-Kishore/e2e-detox/commit/8eb5b1ef469b7236d880717d9f439b802a6f1ade">commit</a> which shows the required file changes. ⚠️</p><h3>🔰 Phase 2 — Write a test</h3><p>To see if things fall in place, let’s add a test id and assert it.</p><p>📃 <em>App.js</em></p><pre>&lt;Text  testID=&quot;desc-text&quot; style={styles.sectionDescription}&gt;</pre><p>📃 <em>e2e/firstTest.spec.js</em></p><pre>describe(&#39;Example&#39;, () =&gt; {<br>      beforeEach(async () =&gt; {<br>        await device.reloadReactNative();<br>      });</pre><pre>      it(&#39;should have description text on welcome screen&#39;, async () =&gt; {<br>        await expect(element(by.id(&#39;desc-text&#39;))).toBeVisible();<br>      });</pre><pre>    });</pre><h3>🔰 Phase 3 — Build</h3><h4>Build a release</h4><p><em>iOS:</em></p><pre>detox build -c ios.sim.release -l verbose</pre><p><em>Android:</em></p><pre>detox build -c android.emu.release -l verbose</pre><h3>🔰 Phase 4 — Test</h3><h4>Test a release</h4><p><em>iOS:</em></p><pre>detox test -c ios.sim.release -l verbose</pre><p><em>Android:</em></p><pre>detox test -c android.emu.release -l verbose</pre><p>Your tests should be passing with flying colors 🌈</p><h3>🔰 Phase 5 — Setting up automation</h3><p>Where is the fun without automating the entire workflow;</p><p>It’s an 🐘 on it’s own, will try to address them individually.</p><ul><li>Integration with CircleCI</li><li>Integration with TravisCI</li></ul><p>Check out the github <a href="https://github.com/Jeevan-Kishore/e2e-detox">repo</a> for the entire codebase 🔥</p><p>If you have questions, let us know in the comments and we are looking forward for your feedback 🍻</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8a0db5bf4a83" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[React navigation v5]]></title>
            <link>https://medium.com/@kishor080/react-navigation-v5-a01394b02118?source=rss-a87ea2a25742------2</link>
            <guid isPermaLink="false">https://medium.com/p/a01394b02118</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[navigation]]></category>
            <dc:creator><![CDATA[Jeevan Kishore]]></dc:creator>
            <pubDate>Thu, 30 Apr 2020 04:27:24 GMT</pubDate>
            <atom:updated>2020-04-30T04:27:24.768Z</atom:updated>
            <content:encoded><![CDATA[<p>Traversing the corners of your app with the helping hand of react-navigation</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*hSd75Z15NyR3ATTWB-eP8A.jpeg" /></figure><p>With the launch of <a href="https://www.npmjs.com/package/@react-navigation/native">react native v5</a> about 3 months ago backed by neat <a href="https://reactnavigation.org/docs/getting-started">documentation</a> making life easier with hooks usage and native transitions, we decided to revamp our current navigation.</p><h3>Problem:</h3><p>Build a navigation system for a an app serving to showcase news content such as collections and stories with configurable paywall to facilitate pay per article / premium content across devices</p><h3>Design:</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/284/1*6SIkdYLvPayzYN9w57oyyQ.png" /><figcaption>Homescreen frame</figcaption></figure><ul><li>Main screen consists of <a href="https://reactnavigation.org/docs/bottom-tab-navigator">bottom tab navigation</a> of about 4 tabs</li><li>Listing screens to showcase categories / sections</li><li>Generic content screens to portray content</li></ul><h3>Architecture:</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/851/1*QB3DGweTLwqP4QtfvmyU9g.png" /><figcaption>Architecture 101</figcaption></figure><blockquote>App.js</blockquote><p>The root of your application needs to be enclosed within a navigation controller, the children of which would be the stack of screens. This will helps us separate concerns b/w auth flows such as login stack and other flows in our case</p><pre>import { NavigationContainer, useLinking } from &quot;@react-navigation/native&quot;;<br>import { createNativeStackNavigator } from &quot;@react-navigation/native-stack&quot;;<br>import { enableScreens } from &quot;react-native-screens&quot;;</pre><p>enableScreens needs to be initiated before the first render item, this gives us a perf boost as it uses native view’s</p><pre>enableScreens(); <br>const [initialState, setInitialState] = useState();</pre><p>the return statement would look like:</p><pre>&lt;NavigationContainer initialState={initialState} ref={ref}&gt;<br>         &lt;Stack.Navigator<br>           screenOptions={{<br>             headerShown: false<br>           }}<br>           initialRouteName=&quot;modalStack&quot;<br>         &gt;<br>           &lt;Stack.Screen name=&quot;modalStack&quot; component={ModalStack} /&gt;<br>           &lt;Stack.Screen name=&quot;loginStack&quot; component={LoginStack} /&gt;<br>         &lt;/Stack.Navigator&gt;<br>       &lt;/NavigationContainer&gt;</pre><blockquote><em>modal-stack.js</em></blockquote><p>The stack is composed of multiple screens which relate in terms of genre in our case.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/318/1*eyx3rqwfM5UGrxxawFe3HA.png" /><figcaption>Content screen frame</figcaption></figure><p>The noticeable aspect is that the stacks are nested, BottomTabStack is nested within the modal stack and that will be the initial route where our app should land post launch</p><pre>import React from &quot;react&quot;;<br>import { BottomTabStack } from &quot;../bottom-tab-navigators/bottom-tab-stack&quot;;<br><br>import { createNativeStackNavigator } from &quot;@react-navigation/native-stack&quot;;<br>import { SCREEN_LIST, STACK_LIST } from &quot;../../constants/screen-mapping&quot;;<br><br>/* Import screen components such as AuthorsScreen, StoryScreen ... */<br><br>const Stack = createNativeStackNavigator();<br><br>export const ModalStack = () =&gt; (<br>  &lt;Stack.Navigator<br>    screenOptions={{<br>      headerShown: false<br>    }}<br>    initialRouteName={STACK_LIST.bottomTabStack}<br>  &gt;<br>    &lt;Stack.Screen name={SCREEN_LIST.authorScreen} component={AuthorsScreen} /&gt;<br>    &lt;Stack.Screen name={SCREEN_LIST.storyScreen} component={StoryScreen} /&gt;<br>    &lt;Stack.Screen name={SCREEN_LIST.bookMarkScreen} component={BookMarkScreen} /&gt;<br>    &lt;Stack.Screen name={STACK_LIST.bottomTabStack} component={BottomTabStack} /&gt;<br>  &lt;/Stack.Navigator&gt;<br>);</pre><blockquote><em>bottom-tab-stack.js</em></blockquote><pre>import React from &quot;react&quot;;<br><br>import { createBottomTabNavigator } from &quot;@react-navigation/bottom-tabs&quot;;<br><br>/* Import necessary constants and components.. */<br><br>const Tab = createBottomTabNavigator();<br><br>const tabBarStyle = {<br>  activeTintColor: &quot;blue&quot;,<br>  style: {<br>    paddingTop: 5<br>  }<br>};<br><br>const TabIcons = (focused, icon) =&gt; {<br>  const iconColor = focused ? &quot;blue&quot; : &quot;black&quot;; /* highlight with a diff color if focused */<br><br>  switch (icon) {<br>    case &quot;home&quot;:<br>      return &lt;HomeIcon color={iconColor} /&gt;;<br>    case &quot;sections&quot;:<br>      return &lt;SectionIcon color={iconColor} /&gt;;<br>    case &quot;search&quot;:<br>      return &lt;SearchIcon color={iconColor} /&gt;;<br>    case &quot;my-app&quot;:<br>      return &lt;MyAppIcon color={iconColor} /&gt;;<br>    default:<br>      break;<br>  }<br>};<br><br>export const BottomTabStack = () =&gt; (<br>  &lt;Tab.Navigator tabBarOptions={tabBarStyle}&gt;<br>    &lt;Tab.Screen<br>      name={BOTTOM_TAB.bottomHomeTab}<br>      component={HomeScreen}<br>      options={{<br>        tabBarIcon: ({ focused }) =&gt; TabIcons(focused, &quot;home&quot;),<br>        title: &quot;Home&quot;,<br>        tabBarTestID: &quot;test-id-home&quot; /* test id&#39;s for use by automation test tools */<br>      }}<br>    /&gt;<br>    &lt;Tab.Screen<br>      name={BOTTOM_TAB.bottomCategoryTab}<br>      component={CategoryScreen}<br>      options={{<br>        tabBarIcon: ({ focused }) =&gt; TabIcons(focused, &quot;sections&quot;),<br>        title: &quot;Sections&quot;,<br>        /* Unique identifier to target category tab */<br>        tabBarTestID: &quot;test-id-categ&quot;<br>      }}<br>    /&gt;<br>    &lt;Tab.Screen<br>      name={BOTTOM_TAB.bottomSearchTab}<br>      component={SearchScreen}<br>      options={{<br>        tabBarIcon: ({ focused }) =&gt; TabIcons(focused, &quot;search&quot;),<br>        title: &quot;Search&quot;,<br>        tabBarTestID: &quot;test-id-search&quot;<br>      }}<br>    /&gt;<br>    &lt;Tab.Screen<br>      name={BOTTOM_TAB.bottomProfileTab}<br>      component={ProfileScreen}<br>      options={{<br>        tabBarIcon: ({ focused }) =&gt; TabIcons(focused, &quot;my-app&quot;),<br>        title: &quot;My App&quot;,<br>        tabBarTestID: &quot;test-id-profile&quot;<br>      }}<br>    /&gt;<br>  &lt;/Tab.Navigator&gt;<br>);</pre><blockquote><em>login-stack.js</em></blockquote><p>This stack isolates the auth-flow</p><pre>import React from &quot;react&quot;;<br>import { createNativeStackNavigator } from &quot;@react-navigation/native-stack&quot;;<br><br>/* Import screen components such as Login, SignUp ... */<br><br>const Stack = createNativeStackNavigator();<br><br>export const LoginStack = () =&gt; (<br>  &lt;Stack.Navigator<br>    screenOptions={{<br>      headerShown: false<br>    }}<br>  &gt;<br>    &lt;Stack.Screen name={SCREEN_LIST.loginScreen} component={Login} /&gt;<br>    &lt;Stack.Screen name={SCREEN_LIST.registrationScreen} component={SignUp} /&gt;<br>    &lt;Stack.Screen name={SCREEN_LIST.forgotPasswordScreen} component={ForgotPassword} /&gt;<br>  &lt;/Stack.Navigator&gt;<br>);</pre><p>With that being set, we can begin surfing 🏄 through the screens</p><p>If we are navigating within a stack:</p><pre>navigation.navigate(&quot;&lt;&lt;screen_name&gt;&gt;&quot;, {&lt;&lt;key&gt;&gt;: &lt;&lt;val&gt;&gt;});</pre><p>If we do need to navigate across stacks:</p><pre>navigation.navigate(&quot;&lt;&lt;stack_name&gt;&gt;&quot;, {  <br>                     screen: &lt;&lt;screen_name&gt;&gt;,<br>                     params: {&lt;&lt;param_key&gt;&gt; : &lt;&lt;param_val&gt;&gt;}<br>                   });</pre><p>There are a lot of ground to cover with react-navigation such as <a href="https://reactnavigation.org/docs/navigation-events/">events</a>, <a href="https://reactnavigation.org/docs/navigation-lifecycle">lifecycles</a> and much more ..</p><p>Will be dropping in a github repo link for an example soon 🔥</p><p>If you have questions, let us know in the comments and we are looking forward for your feedback 🍻</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a01394b02118" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>