<?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 Amit Ranan on Medium]]></title>
        <description><![CDATA[Stories by Amit Ranan on Medium]]></description>
        <link>https://medium.com/@amituuush?source=rss-c655191befa2------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*hGph-w9qbpdFFnHW.jpg</url>
            <title>Stories by Amit Ranan on Medium</title>
            <link>https://medium.com/@amituuush?source=rss-c655191befa2------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 13:11:51 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@amituuush/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[Async Actions with Redux]]></title>
            <link>https://medium.com/@amituuush/async-actions-with-redux-ad39a975ec80?source=rss-c655191befa2------2</link>
            <guid isPermaLink="false">https://medium.com/p/ad39a975ec80</guid>
            <category><![CDATA[redux]]></category>
            <category><![CDATA[ajax]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Amit Ranan]]></dc:creator>
            <pubDate>Fri, 23 Dec 2016 21:13:37 GMT</pubDate>
            <atom:updated>2016-12-23T21:13:37.768Z</atom:updated>
            <content:encoded><![CDATA[<p>Dispatching actions to retrieve a user input or delete an item off a list allow apps to be dynamic, but what happens when you want to load data into your app from your api server or from a third-party api?</p><p>There are several ways to implement asynchronous requests in a Redux application. First, let’s talk about where you make the request itself. Should it be made in a reducer or in an action creator? The answer is in the action creator, but let’s look at why you wouldn’t want to make an async request in a reducer.</p><p>Simply put, reducers must be pure functions that take in the current state and an action, and return the next state without modifying the current state. In other words, if a piece of state is an object, a reducer returns a brand new altered object as opposed to changing the object it initially receives. And since pure functions must return the same output given the same input, adding async requests to a reducer would no longer make it a pure function.</p><p>Before we get into the actual request in the action creator, it’s important to note that in order for async actions to exist in an app, the app must have asynchronous middleware installed (as mentioned in the <a href="http://redux.js.org/docs/advanced/AsyncFlow.html">Redux official documentation</a>). Two of the most popular libraries that also deal with promises are redux-thunk and redux-promise. If you’re just trying to dispatch a promise and retrieve a resolved request, redux-promise is the way to go. If you’re looking to construct a conditional promise chain or dispatch multiple promises at one time, redux-thunk is your guy. In this example, we’ll be sticking with redux-promise. Now let’s begin coding.</p><p>First things first, we’ll need to install 2 libraries: redux-promise and axios. You already know what redux-promise does, and axios is a promise based HTTP client aka we’ll be using this to make our async requests. So in the terminal:</p><pre>npm install --save redux-promise axios</pre><p>Next, we need to add redux-promise to our middleware chain. This is done by first importing applyMiddleware and redux-promise, passing redux-promise to applyMiddleware as an argument, and passing applyMiddleware as a second argument to the createStore method, like so:</p><pre>import { createStore, applyMiddleware } from &#39;redux&#39;;<br>import reduxPromise from &#39;redux-promise&#39;;</pre><pre>let store = createStore(<br>  rootReducer,<br>  applyMiddleware(<br>    reduxPromise,<br>  )<br>);</pre><p>This is obviously a simplified version of what one’s store might look like, but we’ll just be stripping down everything besides the libraries and methods we’re using to make these concepts easier to understand.</p><p>Now on to the request and action creator. First import the axios library into the action creator file. And from here it’s pretty simply.</p><pre>import axios from &#39;axios&#39;;</pre><pre>export function fetchData() {<br>  const request = axios.get(&#39;/your-api-url&#39;);</pre><pre>return {<br>    type: FETCH_DATA,<br>    payload: request<br>  }<br>}</pre><p>We make a GET request to our api’s URL, which returns a promise that we set to the payload property of our action. The action then gets sent to middleware. This is where the magic of redux-promise comes in. Once redux-promise receives the action, it assesses the payload property. If it’s a promise, it will stop the action from being sent to the reducers until the promise is resolved. Once the promise is resolved, redux-promise will send a new action with a payload of the resolved response to the reducers. From there, the reducers handle the action like they would any other action.</p><p>So there you have it, asynchronous actions in Redux.</p><p>What we’ve learned: redux-promise makes our life a lot easier.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ad39a975ec80" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Build tools for beginners: Using Gulp (Part 2 of 2)]]></title>
            <link>https://medium.com/@amituuush/build-tools-for-beginners-using-gulp-part-2-of-2-aafa94c26bfa?source=rss-c655191befa2------2</link>
            <guid isPermaLink="false">https://medium.com/p/aafa94c26bfa</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[gulp]]></category>
            <category><![CDATA[task-runners]]></category>
            <dc:creator><![CDATA[Amit Ranan]]></dc:creator>
            <pubDate>Mon, 28 Mar 2016 16:13:01 GMT</pubDate>
            <atom:updated>2016-03-28T16:13:01.953Z</atom:updated>
            <content:encoded><![CDATA[<h4>Creating a Gulpfile</h4><p>We’ll start where we left off by creating the scripts that define Gulp’s build process and how it should handle the files in our project. To get caught up to speed on installing Gulp, see <a href="https://medium.com/@amituuush/build-tools-for-beginners-using-gulp-part-1-of-2-91d3d6e3cc8d#.mjbfvt8r2">part 1</a>.</p><p>Navigate to the root directory of your project and create a file called <strong>Gulpfile.js</strong>. Before writing any scripts, we’ll need to expose our <strong>Gulpfile</strong> to the software packages we installed in part 1. Let’s install a package that will enable us to do this, called <a href="http://browserify.org/"><strong>Browserify</strong></a>. In the command line, type:</p><pre><em>npm install — save-dev browserify</em></pre><p>At the top of your <strong>Gulpfile</strong>, write:</p><pre>var gulp = require(‘gulp’);<br>var jshint = require(‘gulp-jshint’);<br>var browserify = require(‘browserify’);<br>var minifyHTML = require(‘gulp-minify-html’);<br>var sass = require(‘gulp-sass’);</pre><p>You see the pattern here. If there are any other packages you want to install, use the same syntax here. The part within the parenthesis must match the portion of the command line snippet you used to install each package. So for example,</p><pre>npm install gulp-jshint</pre><p>would need <strong>gulp-jshint</strong> within the <strong>require(‘ ’)</strong> parenthesis.</p><h4>Gulp API</h4><p>Gulp has <a href="https://github.com/gulpjs/gulp/blob/master/docs/API.md">5 methods</a> that allow you to do and get what you want. They are:</p><ul><li>src</li><li>dest</li><li>task</li><li>watch</li><li>run</li></ul><p>We’ll start with a simple example. Type the following code in your <strong>Gulpfile</strong>.</p><pre>gulp.task(‘html-min’, function() {<br> return gulp.src(‘client/index.html’)<br> .pipe(minifyHTML())<br> .pipe(gulp.dest(‘build/’));<br>});</pre><p>The <strong>gulp.task()</strong> method states that you are defining a new gulp task. The first parameter of this method takes the task name as a string. In this case, we’ll call it <strong>‘html-min’</strong>, since this task will be minifying our HTML. The second parameter takes a function, where the body of the script will live.</p><p>The <strong>gulp.src </strong>loads the file you pass it, which will be the <strong>index.html</strong> file in our client directory. What you’ll notice next are two more methods that are called sequentially without calling <strong>gulp</strong>. This pattern is known as <strong>method chaining</strong>, and you can read more about it <a href="http://schier.co/blog/2013/11/14/method-chaining-in-javascript.html">here</a> if you’d like.</p><p>The first of these next methods takes the code in our <strong>index.html</strong> file and pipes it into our <strong>minifyHTML()</strong> plugin, which removes any whitespace and unnecessary characters from from our code to allow for better performance. The second of these next methods spits the now minified code into a directory in your project for you to use. In this case, our new minified <strong>index.html</strong> file will be outputted into the build directory of our project.</p><p>Are we done yet? Almost. We just need to run this task so we can actually get our minified <strong>index.html</strong> code. In the command line, run:</p><pre>gulp html-min</pre><p>Now look in the <strong>build</strong> directory in your project. You should see a new minified version of your code!</p><h4>Let’s do one more</h4><p>Let’s create a <strong>jshint</strong> task, which goes through your JavaScript files and detects any potential problems in your code.</p><pre>gulp.task(&#39;jshint&#39;, <strong>function</strong>() {<br>  <strong>return</strong> gulp.src(&#39;client/js/app.js&#39;)<br>    .pipe(jshint())<br>    .pipe(jshint.reporter(&#39;default&#39;));<br>});</pre><p>Same start as before. We define a new gulp task called <strong>jshint</strong>, and load the <strong>client/js/app.js </strong>file, before piping it into the <strong>jshint </strong>plugin to let it do its thing. Finally, since we only need some information about our code and not a new code output, we’ll pipe the result of <strong>jshint</strong> into <strong>jshint.reporter()</strong>, which then outputs this to the console.</p><p>If we run our new task:</p><pre>gulp jshint</pre><p>We should receive a report in the console that let’s us know of any errors in our JavaScript code. Pretty cool stuff.</p><h4>What if I have 10 tasks? Do I have to run them all individually?</h4><p>Simple answer: no. You can create a build task that runs all your tasks! It’s really simple, just follow the following format:</p><pre>gulp.task(‘build’, [‘jshint’, ‘html-min’, ‘sass’, ‘scripts-combine’, ‘images’]);</pre><p>First parameter takes the name of the task, and second parameter takes the names of the tasks you want to run in an array.</p><p>Now, when you go to the terminal and run:</p><pre>gulp build</pre><p>All your tasks will run at once :)</p><h4>So I have to run the build task every time I make a change? Is there a way to run the build task whenever I save a file?</h4><p>Indeed there is.</p><pre>gulp.task(‘watch’, function() {<br>gulp.watch(‘client/js/app.js’,[‘jshint’, ‘scripts-combine’]);<br>gulp.watch(‘site/scss/*.scss’, [‘sass’]);<br>gulp.watch(‘site/index.html’, [‘html-min’]);<br>});</pre><p>The <strong>watch</strong> task is a built-in task that automatically runs a specified task when a specified file is saved. Technically, we can call it whatever we want, but the <strong>gulp.watch()</strong> method takes the name of the file you want to watch as the first parameter, and the name of the task you want to run as the second.</p><p>I hope this intro to <strong>Gulp</strong> has given you a solid understanding of the basics of task automation and how to implement <strong>Gulp</strong> into your next project. If you have any thoughts or ideas, feel free to share in the comments :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aafa94c26bfa" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Build tools for beginners: Using Gulp (Part 1 of 2)]]></title>
            <link>https://medium.com/@amituuush/build-tools-for-beginners-using-gulp-part-1-of-2-91d3d6e3cc8d?source=rss-c655191befa2------2</link>
            <guid isPermaLink="false">https://medium.com/p/91d3d6e3cc8d</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[gulp]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Amit Ranan]]></dc:creator>
            <pubDate>Tue, 23 Feb 2016 06:28:49 GMT</pubDate>
            <atom:updated>2016-02-23T06:28:49.307Z</atom:updated>
            <content:encoded><![CDATA[<h4>Intro to Gulp</h4><p>If you already know what gulp is and understand its benefits, skip down to <strong>Installation</strong>.</p><p>What is a build tool and what is Gulp? Why should I care? Let’s identify some common pain points for beginning developers who have not been introduced to build tools.</p><ul><li>Concatenating JavaScript files every time you want to check if your code works.</li><li>Copy and pasting all your code in <a href="http://www.jslint.com/">jslint.com</a>, or some other code quality tool to figure out where you bug is.</li><li>Refreshing your browser every time you want to see the output of your most recent code.</li><li>Copy and pasting all your code into an online minifier every time you want to see how fast your app truly is.</li><li><strong>Point is: there are too many tedious and mundane tasks that continually need to be completed when building web apps.</strong></li></ul><p>Fortunately, one of the biggest reasons software even exists is to automate repetitive tasks in order to make our lives easier. We as developers can leverage this inherent quality to automate the very tasks that need to be completed to build the software itself. Pretty cool stuff.</p><p>This is precisely what Gulp helps us do: automate tedious and mundane tasks.</p><h4>Installation</h4><p>Before installing anything, make sure you have your directory structure set up for your project, and navigate to the root directory of your project in the terminal.</p><p>Gulp needs Node.js and NPM (Node Package Manager) to run, so we’ll have to install these first (don’t worry, it’s very easy). If you don’t know what Node.js is, think of it as the framework that Gulp needs in order to function (like a railroad for a train).</p><p>Another thing to know is Gulp alone doesn’t provide you with all the functionality to automate all these tasks. It relies on software packages, also known as “dependencies”, to do so. Simply put, NPM allows you to download these packages (Gulp being one of them).</p><ol><li>To check if you already have Node.js installed, go to your terminal and type:</li></ol><blockquote><strong>node -v</strong></blockquote><p>If you see a version number returned, then Node.js is already installed. Otherwise, use <a href="http://www.wenincode.com/installing-node-jsnpm-without-sudo/">these instructions</a> to install it on a Mac, and <a href="https://github.com/coreybutler/nvm-windows">these instructions</a> on a Windows computer.</p><p><strong>2.</strong> Great! Now to install Gulp, type:</p><blockquote><strong>npm install -g gulp</strong></blockquote><p>If this doesn’t work, add the word “sudo” at the beginning of the previous command, and try it again.</p><p>Again, you can check to see if Gulp is installed by running the following command and seeing a version number returned:</p><blockquote><strong>gulp -v</strong></blockquote><p><strong>3. </strong>The next thing we need to do is initialize your project. Type:</p><blockquote><strong>npm init</strong></blockquote><p>You’ll then need to confirm a few details about your project by hitting enter. Don’t worry about most of the details you have to confirm, you can leave them blank for now. Just enter in the correct project name and author (you).</p><p>Once you’ve completed this process, take a look at your directory tree. See anything different? You should now see a <strong>package.json</strong> file in the root directory of your project. If you open this file, you’ll see many of the details you entered in during the previous step.</p><p><strong>4. </strong>The next step involves installing all the software packages (or dependencies) I mentioned earlier, with Gulp being one of them. In the terminal, enter in:</p><blockquote><strong>npm install --save-dev gulp</strong></blockquote><p>By inserting the <strong>--save-dev </strong>flag, we’re saving gulp as a dependency to our project. It’s basically saying, “Hey NPM, install gulp and save it in my project because it needs gulp to function!”</p><p>You’ll now see a <strong>node_modules </strong>directory in the root directory of your project. This directory stores all the software packages you’ve installed using NPM. No need to mess around with it, let it do its thing.</p><p><strong>5. </strong>Now comes the fun part — we can begin installing all the cool software packages that allow us to automate all those tedious tasks! NPM has over <a href="http://gulpjs.com/plugins/">2,000 software packages</a> (also called “plugins”) you can choose from. For the sake of efficiency, I’ll share with you a few of my favorite plugins.</p><p><a href="https://www.npmjs.com/package/gulp-livereload/"><strong>Live Reload</strong></a>: refreshes your browser page whenever you save a file.</p><p><a href="https://www.npmjs.com/package/gulp-jshint/"><strong>JSHint</strong></a>: a code quality tool that helps detect errors and bugs in your code.</p><p><a href="https://www.npmjs.com/package/gulp-concat/"><strong>Concat</strong></a>: concatenates files so you can use them in production.</p><p><a href="https://www.npmjs.com/package/gulp-uglify/"><strong>UglifyJS</strong></a>: minifies your javascript.</p><p><a href="https://www.npmjs.com/package/gulp-minify-html/"><strong>Minify HTML</strong></a>: exactly what it sounds like.</p><p><a href="https://www.npmjs.com/package/gulp-imagemin"><strong>ImageMin</strong></a>: minifies all image files in your project.</p><p><a href="https://www.npmjs.com/package/gulp-notify"><strong>Notify</strong></a>: send you a desktop notification (maybe my favorite).</p><p>To install a plugin (Live Reload and UglifyJS, for example), you’ll run a similar command as installing gulp:</p><blockquote><strong>npm install --save-dev gulp-livereload gulp-uglify</strong></blockquote><p>You can install one plugin at a time, or as many as you want with one command. Check each plugin’s page on the NPM website for its specific install command. Also make sure to include the <strong>--save-dev </strong>flag when doing so.</p><p>If you navigate to your <strong>package.json</strong> file, you should see all these plugins listed under <strong>devDependencies</strong>.</p><h4>Wrapping Up</h4><p>I hope this tutorial helped you get on your feet with the Gulp build tool. The second part of this tutorial will show you how to build scripts that allow these plugins to do their job in your project.</p><p>Stay tuned. Hope this helps :)</p><p>-Amit</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=91d3d6e3cc8d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Top Sites for JavaScript Practice Exercises]]></title>
            <link>https://medium.com/@amituuush/top-sites-for-javascript-practice-exercises-63f5761d3069?source=rss-c655191befa2------2</link>
            <guid isPermaLink="false">https://medium.com/p/63f5761d3069</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Amit Ranan]]></dc:creator>
            <pubDate>Thu, 11 Feb 2016 06:23:29 GMT</pubDate>
            <atom:updated>2016-02-11T06:32:36.920Z</atom:updated>
            <content:encoded><![CDATA[<p>I started learning JavaScript over a year ago. After completing <a href="https://www.codecademy.com/">codecademy</a> and <a href="https://www.codeschool.com/">codeschool</a>’s JavaScript courses, I was eager to take my newly developed skills to the next level. The biggest problem with online self-paced courses is taking what you’ve learned and applying it to a real application. I finally put my beginner JavaScript skills to use after joining <a href="https://www.thinkful.com/">Thinkful’s</a> full-time Frontend Development bootcamp.</p><p>However, as every developer knows, there’s a lot of necessary work that goes into building the front end of an app aside from just coding in JavaScript (setting up build tools and automation, building a non-interactive version of your app, etc.). If you start building an app right after learning the basics, you may start to feel like you want more practice with purely JavaScript to familiarize yourself more with its vast array of data types, methods, and capabilities (see what I did there?).</p><h4>I surely did, which led me to search the web for JavaScript exercises. Here’s a list of my top 3 sites:</h4><ul><li><a href="https://coderbyte.com/challenges">Coderbyte Challenges</a> — Coderbyte does a great job of offering tons of JavaScript exercises listed by difficulty level. While it isn’t free (aside from ~10 “easy” challenges), $24/mo. gets you access to all their challenges. The best part: they save which challenges you’ve completed (which makes you want to finish them all!), and give countless examples of how others completed each challenge if you get stuck. If you can be diligent about finishing as many as you can in a month, that’s 24 well spent dollars.</li><li><a href="http://nodeschool.io/index.html#workshoppers">NodeSchool Workshoppers</a> — aside from hosting really great events and meetups, NodeSchool’s <em>javascripting </em>and <em>Functional Javascript</em> workshoppers have excellent FREE exercises to work on your JavaScript skills. Heads up: you’ll need to install Node.js on your computer and have a text editor (instructions on NodeSchool link).</li><li><a href="http://www.w3resource.com/javascript-exercises/">w3resource JavaScript Exercises</a> — as I’m sure most developers are familiar with w3resource, they have tons and tons of FREE JavaScript exercises listed by subject. While I have come across a few that were worded poorly, nearly all of them are excellent for practicing your JavaScript skills.</li></ul><p>I hope these resources afford you more time coding in pure JavaScript! If you’re familiar with any other sites that offer JavaScript exercises, I’d love find out about them. Feel free to share them in the comments section :)</p><p>-Amit</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=63f5761d3069" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>