<?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 Harsha attray on Medium]]></title>
        <description><![CDATA[Stories by Harsha attray on Medium]]></description>
        <link>https://medium.com/@Harshattray?source=rss-de778776f214------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*l_mdZUJB9cwPIeAwofj57A.jpeg</url>
            <title>Stories by Harsha attray on Medium</title>
            <link>https://medium.com/@Harshattray?source=rss-de778776f214------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 23:07:04 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@Harshattray/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[A Glimpse into React Server Components]]></title>
            <link>https://levelup.gitconnected.com/a-glimpse-into-react-server-components-bc81c346989a?source=rss-de778776f214------2</link>
            <guid isPermaLink="false">https://medium.com/p/bc81c346989a</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[react-server-component]]></category>
            <dc:creator><![CDATA[Harsha attray]]></dc:creator>
            <pubDate>Thu, 03 Oct 2024 20:14:51 GMT</pubDate>
            <atom:updated>2024-10-06T17:55:20.831Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/851/1*5a4MQaJjRRNSQV9cxj4yew.png" /></figure><h3>Introduction</h3><p>React has for a long period been a key component in the building of dynamic, interactive web apps. With each newer release, a variety of novel features makes modern web development an ever-changing world. Perhaps one of the most exciting things coming to React 19 will be React Server Components, a new hybrid way to do server and client rendering. This might just become game-changing in how developers are going to build up their apps.<br>This article will go into deeper detail about React Server Components: what they are, how it works, the benefits and limitations, best practices when using them, with code examples. That will give us better insights into how to leverage RSCs in our work.</p><h3>What Are React Server Components?</h3><p>React Server Components are a new way to construct components with React, but this time they are rendered on the server and sent to the client as serialized HTML. While CSR does all the heavy lifting of rendering an entire component tree directly within the browser, and SSR populates the first wave of HTML on the server, RSCs have a unique capability to have certain parts of the UI rendered only in the server and then sent down as pure HTML to a client. This approach keeps the client-side JavaScript at a minimum and improves performance; hence, applications powered with React are leaner and faster.<br>Core Characteristics of React Server Components</p><p>No Client-Side JavaScript: In the case of RSCs, the output of the render function gets serialized as HTML and then sent to the client. In other words, there is no client-side JavaScript logic for these components, hence decreasing the bundle size in general.</p><p>Server-Side Capabilities: Server Components can directly interact with server-side resources, including databases, file systems, and backend APIs. It implies that you run your server-only logic, such as database queries, directly within these components.</p><p>Seamless integration with Client Components: RSCs will coexist and interoperate with the traditional Client Components. You, as a developer, would then be able to decide which of the components should be rendered at the server and which ones should handle client-side interactions.</p><p>Reduced Overhead of Data Fetching: Since server components can directly access the data on the server, there will be no need to use useEffect or any other client-side hook for fetching data. This will result in cleaner and more efficient code.</p><p>Streaming Capabilities: Server Components are also capable of streaming incrementally to the client, meaning parts of the UI can be rendered and displayed at the same time as other parts are being fetched or processed on the server.</p><h4>How React Server Components Work</h4><p>The react-runtime, when using RSCs sends the Server-side rendered HTML and a payload of the data across to the client. This payload is then used to hydrate the client which may also be further integrated with Client Components if necessary.<br>Here’s a basic diagram to outline the flow:<br>The browser makes a request to the server to load a React Server Component.<br>The server fetches whatever data is required and renders the component as HTML and sends back the result to the browser.<br>The client receives the HTML and renders in the browser without requiring more JavaScript.<br> <br>This above flow doesn’t require shipping extra JavaScript logic to the client; hence, this would be perfect for those scenarios where initial page load performance is crucial and SEO.</p><h4><strong>Advantages of React Server Components</strong></h4><h4>1. Smaller Client-Side Bundle Size</h4><p>React Server Components allows you to render the static, non-interactive part of your application on the server, so no need to send JavaScript logic to the client. That results in smaller client bundles, smaller downloads, and faster runtime performance on the client. Example: Bundle Size Reduction Using RSCs<br>Lets imagine a component that fetches a list of products and renders them as static HTML. With RSCs you can do the fetching on the server and only send the rendered HTML to the client</p><pre>// src/components/ProductList.server.jsx<br>import React from &#39;react&#39;;<br>import db from &#39;../utils/db&#39;; <br><br>export default async function ProductList() {<br>  const products = await db.getProducts(); <br><br>  return (<br>    &lt;ul&gt;<br>      {products.map(product =&gt; (<br>        &lt;li key={product.id}&gt;<br>          &lt;h2&gt;{product.name}&lt;/h2&gt;<br>          &lt;p&gt;{product.description}&lt;/p&gt;<br>        &lt;/li&gt;<br>      ))}<br>    &lt;/ul&gt;<br>  );<br>}</pre><p>In this example, the ProductList component fetches product data from a server-side database and renders it as HTML. The client only receives the HTML and doesn’t need to include any JavaScript for fetching or managing state.</p><h4>2. Improved SEO and Initial Page Load</h4><p>By sending fully rendered HTML, server-rendered components help with SEO by immediately making content visible to search crawlers. This also reduces TTFB (Time to First Byte) and improves initial page load time.</p><p><strong>Example: Static Content with RSCs for SEO</strong></p><p>Suppose you have a blog post component that you want instantly visible on page load:</p><pre>// src/components/BlogPost.server.jsx<br>import React from &#39;react&#39;;<br>import fs from &#39;fs&#39;;<br><br>export default async function BlogPost({ postId }) {<br>  const markdownContent = await fs.promises.readFile(`./content/${postId}.md`, &#39;utf8&#39;);<br>  return &lt;div dangerouslySetInnerHTML={{ __html: markdownContent }} /&gt;;<br>}</pre><p>Above component reads a markdown file from server’s file system, converts it into HTML and sends the result to the client. Client receives fully rendered HTML which is great for SEO and perceived load time.</p><h4>3. Simpler Data Management</h4><p>By moving data-fetching logic into the server, RSCs drastically reduce the need for complicated client-side state management or effect hooks like useEffect. This keeps things tidy and diminishes the need for numerous network requests</p><p><strong>Example: Fetching Data with Server Components</strong></p><pre>// src/components/UsersList.server.jsx<br>import React from &#39;react&#39;;<br>import fetch from &#39;node-fetch&#39;;<br><br>export default async function UsersList() {<br>  const response = await fetch(&#39;https://jsonplaceholder.typicode.com/users&#39;);<br>  const users = await response.json();<br><br>  return (<br>    &lt;ul&gt;<br>      {users.map(user =&gt; (<br>        &lt;li key={user.id}&gt;<br>          {user.name} - {user.email}<br>        &lt;/li&gt;<br>      ))}<br>    &lt;/ul&gt;<br>  );<br>}</pre><p>This component fetches the data directly from an external API and then renders a list of users right on the server. On the client side, no Data-fetching hooks or state management are required.</p><h4>4. Better Server Resource Utilization</h4><p>Because RSCs execute on the server, they have access to certain server-side resources like database connections, file system access, and environment variables without the need for direct exposure to the client. All this, in turn, further reduces the need to make round trips from client to server and minimizes resources used on the client.</p><h3>Limitations and Trade-Offs</h3><p>While React Server Components come with several advantages, they come with some of the limitations listed below</p><h4>1. Lack of Interactivity</h4><p>Server Components need to be static themselves and are unable to manage any client-side state or handle events upon user interactions such as clicks or form submits. You’d have to combine them with Client Components for such purposes.</p><p><strong>Example: Combining Server and Client Components</strong></p><pre>// src/components/ProductItem.client.jsx<br>import React, { useState } from &#39;react&#39;;<br><br>export default function ProductItem({ product }) {<br>  const [quantity, setQuantity] = useState(1);<br><br>  return (<br>    &lt;div&gt;<br>      &lt;h2&gt;{product.name}&lt;/h2&gt;<br>      &lt;p&gt;{product.description}&lt;/p&gt;<br>      &lt;input<br>        type=&quot;number&quot;<br>        value={quantity}<br>        onChange={e =&gt; setQuantity(e.target.value)}<br>      /&gt;<br>      &lt;button onClick={() =&gt; alert(`Adding ${quantity} items to cart`)}&gt;Add to Cart&lt;/button&gt;<br>    &lt;/div&gt;<br>  );<br>}</pre><p>It can be reused next to a server-side rendered ProductList component, adding interaction to it without including the fetch-products logic on the client.</p><h4>2. Higher Server Load</h4><p>By transferring more and more rendering logic onto the server, that automatically means higher server load. This will likely be more expensive or require more performing infrastructure. Remember balancing server-side and client-side rendering depending on your app needs and expected traffic.</p><h4>3. Compatibility with Third-Party Libraries</h4><p>Most of the React libraries don’t work with RSCs, especially when third-party libraries rely on client-side features like useEffect or other third-party Hooks. And that again leaves you with very limited choices while integrating existing libraries, and may require refactoring or avoidance of those libraries altogether.</p><h4>4. Limited Debugging Tools</h4><p>Well, debugging is a bit trickier because RSCs are rendered on the server. While tools like the React DevTools can support a little in respect to client-side debugging, at times server-rendered components may need additional server-side debugging tools and techniques.</p><h3>When to Use React Server Components</h3><p>RSCs are particularly useful under certain scenarios:</p><ol><li><strong>Static Content Rendering</strong>: Pages or sections of your application that contain mainly static content-such as documentation pages or landing pages.</li><li><strong>SEO-Focused Applications</strong>: Content-heavy sites where SEO is critical, as RSCs ensure the search engines will see all the content.</li><li><strong>Content Delivery with Low Interactivity</strong>: RSCs should be used on pages where the delivery of content is not highly interactive on the client side, for example, some product detail pages or blog posts.</li></ol><h3>When Not to Use React Server Components</h3><p>One should refrain from using RSC in scenarios such as:</p><p><strong>Highly Interactive Applications</strong>: Applications such as chat apps, collaboration tools, or any other highly interactive UI that would involve very complex client-side state management.</p><ol><li><strong>Offline-First or Low Connectivity Scenarios</strong>: Applications that need to work offline or on low server connectivity .</li><li><strong>Real-Time Applications</strong>: Components that update frequently or real-time synchronizations are needed, such as live feeds or dashboards.</li></ol><h3>Conclusion</h3><p>React Server Components are a powerful addition to the React ecosystem in React 19. They allow developers to build faster, more efficient, and SEO-friendly applications by moving rendering logic to the server. However, as with any new technology, it’s important to understand its limitations and use it where it fits best.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bc81c346989a" width="1" height="1" alt=""><hr><p><a href="https://levelup.gitconnected.com/a-glimpse-into-react-server-components-bc81c346989a">A Glimpse into React Server Components</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[An insight into State Management in Microfrontends]]></title>
            <link>https://levelup.gitconnected.com/an-insight-into-state-management-in-microfrontends-a2909366fd82?source=rss-de778776f214------2</link>
            <guid isPermaLink="false">https://medium.com/p/a2909366fd82</guid>
            <category><![CDATA[micro-frontends]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[state-management]]></category>
            <dc:creator><![CDATA[Harsha attray]]></dc:creator>
            <pubDate>Thu, 20 Jun 2024 15:04:03 GMT</pubDate>
            <atom:updated>2024-06-23T13:04:18.365Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*pAkztGcf13N0YuFN" /><figcaption>Photo by <a href="https://unsplash.com/@rosssneddon?utm_source=medium&amp;utm_medium=referral">Ross Sneddon</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Microfrontends and their implementation strategies are something that are widely discussed with plenty of resources available for anyone who’s interest is piqued regarding their functioning , setup and the most fundamental question of all. Do we even need it in our project?</p><p>Here we take a segue and try to answer a deeper question to those who have already decided to take the plunge and are now contemplating on the dreaded question of how to manage the state while using Microfrontends.</p><p>Traditional single page apps (SPAs) have a pretty straight forward approach to state management. But when it comes to Microfrontends, the state can be managed globally using libraries like Redux, Vuex, or MobX. However, in a microfrontend architecture, each microfrontend might be developed with different frameworks and libraries, making global state management more complex.</p><p>A rough overview of the types of state in MicroFrontends leads us to two branches , local state (state specific to a particular microfrontend and not shared with others) and shared<strong> </strong>State (state that needs to be shared across multiple Microfrontends, such as user authentication status, application-wide settings, or shared data models.)</p><h3>The Challenge and Strategies</h3><p>Lets look at a few strategies that can be employed that will probably make our lives easier. Again , these are generic strategies and you are free to cherry pick whichever suits your project</p><h4>Isolated State</h4><p>Here, each Microfrontend manages its own state independently , this approach ensures Microfrontends are truly decoupled and can operate individually.</p><p>Imagine a dashboard application with two microfrontends: UserProfile and UserSettings. Each microfrontend manages its own state independently.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-Rh14gGcsHhfqCim_k_j4w.png" /><figcaption>UserProfile Component</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G3zh3jz1xNdKEt0WmhfpLg.png" /><figcaption>UserSettings Component</figcaption></figure><p>let us list the pros and cons in the above approach.</p><p>Pros: <br>Among the pros , I would count that each Microfrontend handles its own state, reducing complexity also Microfrontends remain truly independent, allowing for easier maintenance and updates.</p><p>Cons: <br>Among the cons, I would say sharing state between microfrontends becomes cumbersome. Also, common state management logic might be duplicated across multiple microfrontends.</p><h4>Event Bus</h4><p>An event bus can facilitate communication between Microfrontends by broadcasting events. Libraries like Node.js’ EventEmitter or some sort of custom implementations can be used to create an event-driven architecture</p><p>Let us look at an example to understand this usecase and it’s implementation better. Consider an application with UserProfile and Notification microfrontends. The Notification microfrontend should display a message when the user profile is updated.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*_On7UTAHpMAXtghTsIYoJA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bJ-BEX6OiALMCkf4OKEClg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n6n-yyXU4vjoLeg4cD-uSw.png" /></figure><p>The above examples give us a fairly trivial example on how event bus could be employed as an alternative. Lets look at the pros and cons of this approach</p><p>Pros<strong>:</strong></p><p>One pro that I’ve observed is that the Microfrontends remain loosely coupled, as they communicate via events. Also interms of scalability , the system can easily scale as more Microfrontends are added.</p><p>Cons<strong>:</strong></p><p>One bottleneck could be managing event names and ensuring no conflicts and that can be challenging. Also , tracing the flow of events and debugging can become complex.</p><h4>Shared State Library</h4><p>A shared state library , something on the lines of redux that can manage state centrally, something that could be imported and be used across the Microfrontends and help maintain consistency</p><p>Below we discuss and example depicting how shared state using redux would work within a Microfrontend environment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Cmy7DLq8Wa-1ZWtyFNoIcQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*parr6uvY_gbYc7xNCZ1lwQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*z7_Da41kNWeW6qORiXZN2g.png" /></figure><p><strong>Pros:</strong></p><p>One of the pros would be , a single source of truth ensures consistency across microfrontends. Also , state changes are predictable and easier to manage.</p><p><strong>Cons:</strong></p><p>Cons to this approach would be Microfrontends become dependent on the shared state library, reducing their independence and a centralized state management might lead to performance bottlenecks.</p><h4>Custom Middleware</h4><p>If you’re feeling adventurous, you can implement a custom middleware if none of these approaches fit into your use-case. You can write a middleware that can handle state synchronization between microfrontends. This middleware should be able to intercept actions and update the state accordingly, providing a flexible state management solution.</p><p>Let us look at an example to this effect — a banking application with TransactionHistory and AccountSummary Microfrontends, requiring synchronized state updates.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Zj0BYyJcfhTo8ehOxryehA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*42826-QqpVN3BNh9_zdN0Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*38pY46VK5eZxg6r7AFe5AA.png" /></figure><p><strong>Pros: <br></strong>In this approach, the middleware provides fine-grained control over state synchronization. it can also help decouple state management logic from microfrontends.</p><p><strong>Cons: </strong>Implementing and maintaining custom middleware adds to the complexity.Ensuring the middleware stays up-to-date and functions correctly requires ongoing effort.</p><p>Here we have discussed an fairly limited approach on how to approach state management while using MicroFrontends , we can further discuss best practices that can be employed while implementing these strategies.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a2909366fd82" width="1" height="1" alt=""><hr><p><a href="https://levelup.gitconnected.com/an-insight-into-state-management-in-microfrontends-a2909366fd82">An insight into State Management in Microfrontends</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[Supercharged functional components with Hooks]]></title>
            <link>https://medium.com/front-end-weekly/supercharged-functional-components-with-hooks-3c4f77d2b31b?source=rss-de778776f214------2</link>
            <guid isPermaLink="false">https://medium.com/p/3c4f77d2b31b</guid>
            <category><![CDATA[functional-programming]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[hooks]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[reactjs]]></category>
            <dc:creator><![CDATA[Harsha attray]]></dc:creator>
            <pubDate>Mon, 18 Feb 2019 20:14:02 GMT</pubDate>
            <atom:updated>2019-11-11T20:23:13.103Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L-i89RXb4e4iW5ff7ODB-A.png" /></figure><p>Having worked with class-based components in React, they seemed to have a lot of functionality with the availability of life-cycle methods and access to the state at any given point of time.</p><p>Functional components though put forth a much more predictable and cleaner approach in building components without the hassle and unpredictability that state and its band of lifecycle methods brought with them. It provided a way for us to build the UI as a pure function of props. This itself did serve as a handicap and a significant limitation to what could be achieved with functional components.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fupscri.be%2Ff%2F788447%3Fas_embed%3Dtrue&amp;dntp=1&amp;display_name=Upscribe&amp;url=https%3A%2F%2Fupscri.be%2F788447%2F&amp;type=text%2Fhtml&amp;schema=upscri" width="800" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/18214d8333adbb5668f31791a3202b60/href">https://medium.com/media/18214d8333adbb5668f31791a3202b60/href</a></iframe><p>Wouldn’t it be amazing to have access to state within the functional components and bypass the multitude of complicated life-cycle methods while at the same time providing a simpler alternative with more or less similar functionality? Well this is sort of addressed with Hooks. Hooks provide the much-needed shot in the arm to a pretty one-dimensional approach that functional components had.</p><h4><strong>A Brief overview of the Hooks ecosystem</strong></h4><p>Hooks were made available in the React v16.8 release. Hooks are just functions and like any other function, the prefix use demarcates hooks from other functions within the react ecosystem. Let’s dive in for a brief overview of the most commonly used Hooks.</p><h4>useState()</h4><p>The useState hook as its name suggests gives us the ability to update and access to the current state. As mentioned earlier, hooks are nothing more than functions and this function takes in an initial state value which could either be a string, object, an array, etc. The useState hook returns an array with two elements, the first one being the full current state and the second being a function to update it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FjMdS27VmtWr05QiuZkQlA.png" /><figcaption>useState() hook</figcaption></figure><p>The second element returned by the useState array is the function which can be used to alter the state. One point that should be noted is that we can call multiple instances of useState within a functional component, but any instance of a hook should only be called at the top level of the functional component.</p><h4>useEffect()</h4><p>useEffect() hook needs to be passed a function that needs to be executed on the component load. It gets called on each render cycle hence it has to be noted that the callback function that is being passed to the useEffect() hook will be executed on each render apart from the first load of the component unless conditionally prevented to do so.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Mya8uOQ-50G424Wkrm13Ow.png" /><figcaption>useEffect() hook example</figcaption></figure><p>useEffect() takes in two arguments, one is the function that it executes and the other is an array of values that it looks at before the function block is executed. This is pretty handy in controlling the execution of useEffect() on each render as, if this array is provided a value then useEffect() executes the function block only if the value within that array has changed post the initial execution. This ensures unnecessary execution of the hook. But bear in mind that if the array argument is left empty then we expect useEffect() to execute on each render cycle. This kind of emulates the componentDidMount() and componentDidUpdate() functionality. Once these are run, there might be a need to clean up the effect in certain situations. We can achieve this by returning a function from within the first function passed to the useEffect() hook. This serves as a cleanup block runs on each render cycle and react runs this before it runs the effect of your main code.</p><h4>useReducer()</h4><p>useReducer() hooks bring in the ability to access the reducer function blocks along with the power to dispatch actions within a functional component.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PrH9tLFff0QManIK6W1ieA.png" /><figcaption>useReducer() hook example</figcaption></figure><p>This takes in three arguments, a reducer function, initial state value and an action that can be immediately dispatched. The useReducer() hook returns an array much like the useState() hook, but here we get access to the state object and the dispatch function whose use cases are pretty self-explanatory.</p><p>Apart from the above-mentioned hook functions, there are other honorable mentions like useContext() , useRef() , useMemo() among others. All in all, hooks do seem to not only supercharge functional components but also simplify and give us a direction that takes us away from the class-based components.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3c4f77d2b31b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/front-end-weekly/supercharged-functional-components-with-hooks-3c4f77d2b31b">Supercharged functional components with Hooks</a> was originally published in <a href="https://medium.com/front-end-weekly">Frontend Weekly</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Performance Optimization and Code Splitting]]></title>
            <link>https://medium.com/@Harshattray/performance-optimization-and-code-splitting-9fd55adfcde?source=rss-de778776f214------2</link>
            <guid isPermaLink="false">https://medium.com/p/9fd55adfcde</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[es6]]></category>
            <category><![CDATA[webpack]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[web-performance]]></category>
            <dc:creator><![CDATA[Harsha attray]]></dc:creator>
            <pubDate>Sun, 15 Jul 2018 18:19:03 GMT</pubDate>
            <atom:updated>2018-07-29T11:19:39.665Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gBEhctfnR2oO21Sqwc5rLA.png" /></figure><p>Performance of a website is heavily dependent on the amount of assets we ship with it , and more often than not it comes down to heavy bundles being pushed on first load, overburdened with code that might not even be needed for that initial page load.</p><p>Incase of relatively slower connections and especially on mobile devices this seemingly normal process tends to get magnified and what we get is a webpage gasping to see the first light and a user who has already given up.</p><p>If we want to see the exact amount of unused code in any given webpage, we can turn over to the Code Coverage feature of the chrome dev tools. It gives you a clear picture of what percentage of code that is being shipped in the current page load is actually being used for that purpose.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eWvbf7kCXXODVhz_U7gTJQ.png" /><figcaption>Chrome Dev tools code coverage</figcaption></figure><p>Let us consider the above snapshot, the initial load size is about 5.2 MB and 43% of it is unused and not needed for that page to load. Imagine the performance upswing that can be achieved by reducing that size and relieving it of most of the unused code if not all of it.</p><p>One solution that webpack offers to this problem is code-splitting. It essentially splits our big blob of JS into asynchronous chunks at build-time, so that these can be selectively called if and only when they are required.</p><p>Code-splitting can be implemented statically or dynamically, even though the dynamic code splitting essentially contains a static relative path.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3mXbT6nyrsKvHQmMCD7D1g.png" /><figcaption>A simple overview of a code-splitting block</figcaption></figure><p>As seen in the above snippet, we import a specific JS file using the dynamic import syntax and trigger it later, in this case a click event.The dynamic import from any JS file takes in the default exports that are declared within it. getSpecificChunk returns a promise which when resolved gives us the contents of that imported file which is requested asynchronously in the form of a new chunk.</p><p>Employing Code-splitting to large codebases can drastically improve load times, impacting the overall performance.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9fd55adfcde" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[An insight into Javascript Generators]]></title>
            <link>https://medium.com/front-end-weekly/an-insight-into-javascript-generators-3f8f5110198c?source=rss-de778776f214------2</link>
            <guid isPermaLink="false">https://medium.com/p/3f8f5110198c</guid>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[generator]]></category>
            <category><![CDATA[es6]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Harsha attray]]></dc:creator>
            <pubDate>Mon, 25 Jun 2018 17:06:52 GMT</pubDate>
            <atom:updated>2018-08-20T15:29:43.360Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/820/1*-TVCqzUbETZL6WGMlQtvqw.png" /></figure><p>In the <a href="https://medium.com/@Harshattray/control-flow-within-generators-in-javascript-753b875cd9b0">previous post written Eons ago</a> we went through what generators are and and how the control shifts in and out of the function during the course of its execution. We also went through the next() call that drives the flow along with yield . In this write up we will delve deeper in to the generators’ flow along with Generator delegation,Symbol Iterators among other things.</p><h3>The for…of phenomenon</h3><p>Let us consider a generator function that yields multiple values. Now executing the .next() call for each yield is something that we can bypass using the for...of loops . This gives us the flexibility to loop through different kinds of data structures.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*k7Or4VCrbJu5njwUwt8jSg.png" /></figure><p>In the above example we create a vegetablesOnMyList() generator function , the aim is to add a new value using yield and push them into an array. Traditionally we would define the generator function , the flow then exits at each occurrence of the yield statement , goes out and searches for the .next() function and then re-enter the generator back at the very same yield point where it left . Now, executing the .next() function might appear a bit too cumbersome , a way out of this is by using the for...of loops, this runs through the generator function once per each yield call. In the above example we loop through our function and the result is pushed into an array.</p><h3>Generator Delegation</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Eek3AsIBWJe1bxWFTA_ysA.png" /></figure><p>In the above code snippet we have an object and say we need to iterate through only selective keys within the object . We create a generator with multiple yield statements to handle this use case, lets call it the UniversityIterator. This generator function is then fed to the for...of loop</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G2Pkt-OcAyo4YaucxDyizw.png" /></figure><p>In the above example we have another object project added to the mix and the idea is to have one generator function to iterate over both the objects, delegating from the top object into the second object. We do create a separate iterator for the projects object but that is eventually mapped to the main generator function that is fed to the for...of loop.</p><p>We trigger the second generator(ProjectIterator) from within the first generator(UniversityIterator) and pass on the object to it . In order to trigger the ProjectIterator we pass the projectGenerator to the yield statement. The detail array now loops through both the objects.</p><h3>Symbol Iterators</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KSmVFGJS91YxZNHfXAMLVg.png" /></figure><p>In the above code snippet , it would be great if the projects object could iterate over itself rather than having a separate function to do that. The [Symbol.iterator] key acts as a reference point to the for...of loop so that it can iterate over the given object. The this keyword in the above example points to the projects object.[Symbol.iterator] can be considered as a dynamically generated valid key value based on the ES6 key interpolation . The value here is a generator function on which the for...of loop runs. Since Symbol Iterators are being used here , we can get rid of the ProjectIterator function.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W6At_iAO3IBASLbK9tSzJA.png" /></figure><p>The University object is refactored to use the [Symbol.iterator] property. We employ Generator Delegation here to loop through the project object and since we don’t need the University Iterator generator , we get rid of it and loop through the University object directly in the for...of loop.</p><h4>Conclusion</h4><p>In this post I’ve tried to explore the use-cases of generators. This along with the <a href="https://medium.com/@Harshattray/control-flow-within-generators-in-javascript-753b875cd9b0">previous</a> introductory post should provide a good enough insight into how generators work in Javascript and how powerful they can be.</p><p>For more insight on Frontend Development checkout the weekly newsletter at <a href="http://frontendweekly.co/">http://frontendweekly.co/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3f8f5110198c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/front-end-weekly/an-insight-into-javascript-generators-3f8f5110198c">An insight into Javascript Generators</a> was originally published in <a href="https://medium.com/front-end-weekly">Frontend Weekly</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Demystifying State Management and Redux]]></title>
            <link>https://levelup.gitconnected.com/demystifying-state-management-and-redux-4ccbb1a1167a?source=rss-de778776f214------2</link>
            <guid isPermaLink="false">https://medium.com/p/4ccbb1a1167a</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[redux]]></category>
            <category><![CDATA[frontend-development]]></category>
            <category><![CDATA[es6]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Harsha attray]]></dc:creator>
            <pubDate>Mon, 28 May 2018 12:55:01 GMT</pubDate>
            <atom:updated>2018-08-01T21:13:49.740Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/784/1*jfzDKX7sSN6XcRUGBAfP8A.jpeg" /></figure><p>The fundamental constituents of any app are its UI and the Application State. The sanctity and predictability of the Application State are paramount for any application. In order to make this task simpler we have state management libraries. In this write up I will dive in to the need for state management and also give an insight into how redux works.</p><h4><strong>Need for State Management</strong></h4><p>Usually we have the UI and the state typically spread across the app. In a react based application, the state is spread across the components and across the DOM itself.</p><p>This scattered state poses a multitude of challenges where more than one component requires access to the same piece of state — Typically we move the state to the parent component and pass it forward as props to the component that needs it. What if the component that needs it is 6–7 levels beneath the parent component. This practice, though not wrong, is pretty cumbersome and tedious. If all of our state is in the Redux state tree we don’t need to worry about all this, the component that needs it can pick it up from the state tree directly.</p><p>So Instead of having the state spread across the app, what if we have it one location.This is what we refer to as the <em>State Tree.</em></p><h4>Interacting with State Tree and understanding how Redux works</h4><p>Now that we have understood the essence and the need for state tree to exist, lets dive deeper and understand how redux facilitates handling of the state tree and the application state in general.</p><p>In order to build a State Management Library these are the building-blocks .</p><ul><li>First we need all of our state in a single location</li><li>Then we need to ‘GET’ the state from the state tree</li><li>‘LISTEN’ to the changes in the state</li><li>‘UPDATE’ the state tree</li></ul><p>All these collectively form our <em>Store.</em></p><h4><em>Building and Interacting with the Store</em></h4><p>Based on the 4 building-blocks mentioned above lets create our createStore() function</p><pre>function createStore(){</pre><pre>// Create the state tree</pre><pre>// GET the state tree - getState()</pre><pre>// LISTEN for changes - subscribe()</pre><pre>// UPDATE the state tree - dispatch()</pre><pre>}</pre><p>Whenever the createStore() function is called the users will have access to the getState() subscribe() and dispatch() methods.</p><h4>Initialising state and the getState function</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DtXwtFQ7hYoDYA90mbycyg.png" /></figure><p>In our createStore() function, we initialise the state and also the getState() function whose task is merely to return the current state. Also the getState() is returned from the main function so that it is accessible as a method when createStore is invoked.</p><pre>const myStore = createStore();</pre><pre>myStore.getState()// returns the current state </pre><h4>Listening for changes using subscribe</h4><p>Now that the state is accessible, we need to listen to changes to the store. We define a subscribe method which acts as a watcher. This method takes in a function as an argument. Since subscribe method can be called multiple times, we use an array to push all the functions that are being watched.</p><p>The user calls subscribe and passes the function and that gets pushed onto the watchers array. To unsubscribe, then we return a call back function which is nothing but the filter array helper checking if the currently passed function already exists in the watchers array. This then returns an array which contains all the other functions except the one that was passed to it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*84gllP92b3z6wppZ69nztA.png" /></figure><h4>Update the State Tree</h4><p>Predictability is the essence of the state management library that we are trying to implement. So, once we have listened to the changes that are to be made to the store , its time we implement those changes.</p><p>Lets say we have a collection of events that are supposed to enforce these updates on the state in our store</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/920/1*PjN48zRSJLWqLLyTK6eanQ.png" /><figcaption>A Sample Action</figcaption></figure><p>Since this is an object, we can add any extra information that we want to which will help us change the state of the store based on the type that is being called.This is called an ACTION — its an object that represents an event that changes the state of our store</p><p>Now that we have our state and actions we need to somehow connect them together. actions must have a type property to specify, well, the “type” of action which is occurring. Other than ‘type’, the structure of the action is quite flexible</p><h4>Reducer functions</h4><p>Reducer functions are supposed to be pure functions that take in the current state and actions and return an updated version of the state without mutating it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9vRCq1OnBEjyJxjtmnJW1g.png" /><figcaption>Reducer functions</figcaption></figure><p>The reducers watch the type of actions getting dispatched and then update the state. If you observe in the above code we are using .concat() instead of .push so that the existing state isn’t mutated</p><h4>Dispatch the Actions</h4><p>Once the reducers are defined , all we need is to be able to ‘dispatch’ an action so that the reducers get their instructions on what and more importantly how to modify the state.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PiB4IS8ZKtUEdYLJwpCZFA.png" /><figcaption>A method to dispatch actions</figcaption></figure><p>Notice that the createStore() now takes in a reducer as a param so that within the dispatch() we can dynamically access the reducers and pass on the actions to get the current state. Once we have the state, we invoke all the functions within our watchers array .</p><p>This above, is our fully functioning State Management Library.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LbwJWo2UckzC2aR1uFuJdg.png" /><figcaption>Accessing the state and methods declared within store</figcaption></figure><h4>Conclusion</h4><p>In this write up I have tried to give an insight into how redux functions . A better understanding of the inner workings might give a much more clearer picture on where and how to use them. Also I’ve stressed on the fact that state’s sanctity is paramount and how redux helps us in maintaining it particularly in large applications.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4ccbb1a1167a" width="1" height="1" alt=""><hr><p><a href="https://levelup.gitconnected.com/demystifying-state-management-and-redux-4ccbb1a1167a">Demystifying State Management and Redux</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[A Snappier approach to Attendance tracking]]></title>
            <link>https://medium.com/@Harshattray/a-snappier-approach-to-attendance-tracking-597ef07b562f?source=rss-de778776f214------2</link>
            <guid isPermaLink="false">https://medium.com/p/597ef07b562f</guid>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[firebase]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[cloudinary]]></category>
            <dc:creator><![CDATA[Harsha attray]]></dc:creator>
            <pubDate>Fri, 13 Oct 2017 12:15:15 GMT</pubDate>
            <atom:updated>2018-07-16T05:00:18.675Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PNF8Txu4iZL2twfKDrLkCA.png" /><figcaption>Image credits: Chumbak | <a href="https://medium.com/u/300ebbca1f61">Melvin John</a></figcaption></figure><blockquote>How we built a real-time attendance tracking application using react-native, Firebase and Cloudinary</blockquote><h3>The Requirement</h3><p>We at <em>Chumbak Engineering</em> were given a responsibility to come forth with a solution to handle tracking the attendance of its ever-expanding workforce at stores across the country as the currently placed system made it quite cumbersome to do that effectively.</p><h3>Prerequisites</h3><p>This article assumes that the reader has previous programming experience, is familiar with Javascript and has a working knowledge of react/react-native.</p><h3>The Solution</h3><p>There were a few options explored to solve this, the most obvious ones include fancy Biometric scanners across the stores. But that didn’t seem a cost effective option. The other option was installing a QR code generator and enable the users to scan uniquely generated codes to mark their attendance. But there was a question of accessibility, the generated QR codes weren’t supposed to be accessible outside the stores.Authentication and Integrity was a point of contention in going ahead.</p><p>So we decided to go ahead with a much more reliable factor,<strong><em>`the users themselves`</em></strong>. The idea was that the users would capture their images from within the store. Now how do we ensure the users are within the store? Location tracking. The solution was expected to be easily accessible, simple and cost-effective. But developing a mobile app for android and iOS separately wasn’t an ideal scenario for a simple attendance tracking app.</p><p>Enter React-native, Facebook’s one stop solution to unite two warring clans of the smartphone ecosystem and sparing us developers from multi platform agony. React-native was perfect for our requirements as it addressed both the platform dilemma and it’s Javascript which runs the show here. The app flow was decided to have Image capture along with location tracking with the standard user authentication. All the data collected here would be accessible on a dashboard with an admin account access.</p><h3>Application flow and stack used</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*D3jbxpdQ3pat-1yVez2TVQ.png" /><figcaption>Complete flow architecture for Dashboard</figcaption></figure><p>Cloudinary served as the image repository offering image transformations on the fly which were quite useful in rendering multiple variations of the same image in the dashboard.</p><h3>App Overview</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6krgEOp0xDdkEUkKh9u-nw.png" /><figcaption><em>App Screens overview</em></figcaption></figure><p>The app consists of 4 major views handled by as many components.</p><ul><li>Login/Signup</li><li>Forgot Password</li><li>Attendance Cam</li><li>Upload Screen</li></ul><h3>User Session walkthrough</h3><p><strong><em>Login Flow/UserDetails gathering</em></strong></p><p>A typical user session in the RAM ecosystem consists of the standard <em>User</em> <em>Login/Signup </em>powered by Firebase email and password authentication. What we aim to establish here is gathering user credentials which can be mapped to the user generated data and stored within the FirebaseDB.</p><p>For any new user, has a simple create user call but this offers limited and restricted scope for customised data gathering. In the snippet below what we did was to embed a firebase database reference path request within the create user call. Here we are populating the FirebaseDB path with the custom fields such as <em>firstname, lastname, email, id. </em>The path being <em>`/employees/info/${currentUser.uid}/` </em>makes sure that the data being written within the firebaseDB is specific to the current user preserving data integrity.</p><pre>firebase.auth().createUserWithEmailAndPassword(email, password).then((user) =&gt; {<br>       this.loginSuccessHandle();<br>       user.updateProfile({<br>         displayName: name,<br>       });<br>const { currentUser } = firebase.auth() firebase.database().ref(`/employees/info/${currentUser.uid}/`).push({<br>         name, email, id<br>       });<br>   this.loginSuccessHandle();<br> }).catch(this.loginFailedHandle.bind(this));</pre><p>Firebase also makes sure that only unique email-ids are permitted to be registered. The extent of customisation can be extended further by adding a separate authentication link to the users’ email id</p><p><em>Image capture/upload/retrieval and beyond</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/768/1*ANBMKlpds8_jZOTQaREeDw.png" /><figcaption>User data flow within the app and dashboard</figcaption></figure><p>The <em>AttendanceCam</em> view is where the user-generated image is captured and stored within the camera-roll. In order to render the cam-view and retrieve the specific image we use <em>react-native-camera.</em></p><pre>&lt;View style={styles.buttonContainer}&gt;<br>    &lt;View style={styles.smallButtonContainer}&gt;<br>     &lt;TouchableOpacity onPress={this.takePicture.bind(this)} <br>      transparent style={styles.captureButton}&gt;<br>       &lt;Image source={require(&#39;../../Images/ic_camera.png&#39;)} /&gt;<br>     &lt;/TouchableOpacity&gt;<br>     &lt;/View&gt;<br>&lt;/View&gt;</pre><p>The camera view generates and captures the image <em>onPress </em>, the generated image is passed onto the <em>Actions.initUpload() </em>object which is a container from <em>react-native-router-flux </em>for route traversal and also for transfer of props from the parent route forward. Props values such as <em>location data,SavedImage, previous check-in/out</em> details are passed on through the <em>Actions.scene().</em></p><pre>const { currentUser } = firebase.auth();<br> const userPath = &quot;/employees/records/&quot; + `${currentUser.uid}`;<br> firebase.database().ref(userPath).on(&#39;value&#39;, (snapshot) =&gt; {<br>             if (snapshot.val()) {<br>                 const dataStore = snapshot.val();<br>                 const lastCheck = dataStore[Object.keys(dataStore)        [Object.keys(dataStore).length - 1]];<br>                 this.setState({<br>                     checkTime: lastCheck.date.toLocaleString()<br>                     .split(&#39; &#39;, 5).join(&#39;&#39;),<br>                     checkSchedule: lastCheck.schedule<br>              });<br>    }</pre><p>The <em>AttendanceCam</em> view also has a function call which checks for the last known attendance submission by the user and retrieves the type and<em> date/time </em>details which are user specific and are passed onto the upload screen to be displayed to the users.</p><p>This brings us to the upload-screen which has two operations enlisted within it</p><ul><li>Cloudinary upload of the image retrieved from props</li><li>FirebaseDB upload of the user generated data</li></ul><p><strong><em>Cloudinary upload of the image retrieved from props</em></strong></p><pre>const SavedImage = this.props.SavedImage;<br>   const url = &#39;https://api.cloudinary.com/v1_1/&#39; + CLOUDINARY_CLOUDNAME + &#39;/image/upload&#39;;<br><br><br>   const signature = sha1(paramsBlock);<br>   const params = {<br>     api_key: CLOUDINARY_API_KEY,<br>     timestamp: timestamp,<br>     upload_preset: uploadPreset,<br>     signature: signature,<br>   }<br>   const uploadStream = superagent.post(url);<br>   uploadStream.attach(&#39;file&#39;, { uri: SavedImage, type: &#39;image/png&#39;, name: &#39;upload.png&#39; })</pre><p>As apparent from the above snippet, params are generated and are passed through <em>sha1 </em>which generates the hashing keys to be passed along with the params to Cloudinary, completing the image upload. The response returns an <em>imageUrl </em>which is where the image is hosted along with a host of other data including time of upload.</p><p>Once retrieved, the <em>imageUrl, </em>along with the other props obtained from the <em>AttendanceCam </em>view are directed towards a FirebaseDB push.</p><p><strong><em>FirebaseDB upload of the user generated data</em></strong></p><p>The data storage/retrieval path generated during <em>createUser</em> phase dealt with obtaining user credentials. Here, we create a new reference path bound to the unique <em>UserId </em>generated by Firebase, the purpose this time around is to push user-generated data obtained so far.</p><pre>const { currentUser } = firebase.auth();<br>   const streetName = this.props.streetName;<br>   const locality = this.props.locality;<br>   firebase.database().ref(`/employees/records/${currentUser.uid}/`)<br>   .push({<br>     date, imageurl, streetName, locality, schedule<br>   });<br>   Actions.successView();<br> }</pre><p>The <em>uploadToDb() </em>function call takes in the date and imageUrl(obtained from Cloudinary response) along with schedule(obtained from FirebaseDB retrieve call) and checks for the current user <em>uid. </em>Params are pushed onto this path<em> `/employees/records/${currentUser.uid}/` </em>upon successful upload, the users are directed to the success view.</p><p><strong><em>Dashboard and Firebase retrieval</em></strong></p><p>The RetailAttendanceMonitor dashboard is hosted on firebase and has a single user login restriction.The Firebase DB rules provide flexibility in terms of who can post and retrieve data from the DB. Here we have userID level access defined.</p><pre>{<br> &quot;rules&quot;: {<br>   &quot;employees&quot;:{<br>     &quot;.read&quot;: &quot;auth.email === &#39;sample@email.com&#39;&quot;,<br>       &quot;$uuid&quot;:{<br>       &quot;.read&quot;: true,<br>         &quot;.write&quot;: true<br>     }<br>   }<br>  }<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/937/1*lUSB4EXOpHOVcbU34zQPEQ.png" /><figcaption>Dashboard Overview</figcaption></figure><p>The dashboard is a 9 column table view which has options to export the retrieved data from Firebase DB into Excel, PDF and CSV formats. This view is sortable and organises the params obtained from the response along with nifty features such as roll-over preview of the images along with thumbnail-view of actual images fetched from Cloudinary transformations. The data once fetched into the Dashboard successfully concludes the life-cycle of a single user session.</p><h3>Where do we go from here</h3><p>Its been over 4 months since the app has been launched for use at our 20+ Chumbak stores across the country. There have been over 13000 user entries as of the time when this blog was being written. In future releases we plan to include offline support along with other features that make life easy for the concerned departments</p><h3>TL;DR</h3><p>Drop a mail to app@chumbak.in if you have any queries. The App along with the dashboard is open-sourced and are available on github. Feel free to use and contribute to the codebase.</p><p><a href="https://github.com/Chumbak/Retailstore-Attendance-Monitor"><strong><em>Click here for the Github open-source repo</em></strong></a></p><p><em>This post was originally published on the </em><a href="https://engineering.chumbak.com/snappier-attendance-tracking/"><em>Chumbak Engineering Blog</em></a></p><h3>Are you a retail chain or a startup?</h3><p>As part of Chumbak’s open source initiative, we are making the whole working application along with the source code for Android &amp; iOS apps available for everyone. You can get the link to the repository at the end of this article. Feel free to talk to us if you have any queries.</p><p>This will be an awesome addition to any retail chains who wants to manage their staff attendance in a gamified way. This will fit for any startups or mid-sized companies as well to track their employee attendance. With this application, user snaps their selfie when they check-in and check-out instead of marking attendance through a register or a biometric device.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=597ef07b562f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Control Flow within Generators in Javascript]]></title>
            <link>https://medium.com/@Harshattray/control-flow-within-generators-in-javascript-753b875cd9b0?source=rss-de778776f214------2</link>
            <guid isPermaLink="false">https://medium.com/p/753b875cd9b0</guid>
            <category><![CDATA[es6]]></category>
            <category><![CDATA[generator]]></category>
            <category><![CDATA[javascript-development]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Harsha attray]]></dc:creator>
            <pubDate>Wed, 11 Oct 2017 19:07:25 GMT</pubDate>
            <atom:updated>2018-06-28T13:23:49.820Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ScdPSOGCXSRsu_PaZlTdcg.jpeg" /><figcaption>Generators In Javascript</figcaption></figure><p>As opposed to normal functions in Javascript, Generators allow us to enter and exit the function multiple times during the course of its execution. As mind-bending as that may sound it turns out that they do come-in quite handy.</p><p>All this is facilitated by the yield keyword that acts as a trampoline to shoot you off and then cushion you back in once you land. Syntactically generators are characterised by a pronounced occurrence of the * symbol within the function declaration.</p><h4>Lifecycle of a Generator</h4><pre>function *buyMeTickets() {</pre><pre>  const ticketStatus =  yield &#39;Don&#39;t have them&#39;;<br>  <br>  return ticketStatus;</pre><pre>}</pre><pre>const result = buyMeTickets();--// execution doesn&#39;t occur here</pre><pre>result.next();<br>result.next(&#39;Booked!&#39;);</pre><p>The block above shows a simple yet valid Generator function. It would be interesting to note that the generator function execution doesn’t begin at its invocation where it is being assigned to result . It is only once the first .next() is called the function starts executing. At this moment, the flow jumps to within the generator where we have the yield keyword with the ticket status. The control takes in the value assigned at the yield and skips ahead to the second result.next() where we are passing in an updated value.</p><p>As with every .next() call, the control switches to within the generator function and updates the value to the whatever that is passed within the .next() . At the end of its execution, the buyMeTickets generator returns an object as follows</p><pre>{value:&#39;Don&#39;t have them&#39;, done: false} // this is during the first- .next() call</pre><pre>{value:&#39;Booked!&#39;, done: true} // this is post the second .next() call and at the end of execution.</pre><p>Generator functions can be better explored and exploited using the for...of loops and the Symbol iterators. This, along with a detailed account of Generator delegation is covered <a href="https://medium.com/@Harshattray/an-insight-into-javascript-generators-3f8f5110198c">here</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=753b875cd9b0" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>