JavaScript ES 2017: Learn Async/Await by Example – codeburst

  • Consider the below code:function doubleAfter2Seconds(x) { return new Promise(resolve = { setTimeout(() = { resolve(x * 2); }, 2000); });}In this code we have a function called doubleAfter2Seconds.
  • Here’s what the boilerplate code looks like:function addPromise(x){ return new Promise(resolve = { // Code goes here… // resolve() });}Awesome.
  • In this example we should be returning x + 2*a + 2*b + 2*c. Here’s the code:function addPromise(x){ return new Promise(resolve = { = { = { = { resolve(x + a + b + c); }) }) }) });}Lets walk through the code again, line by line.First, we create…
  • Here’s what that looks like:async function addAsync(x) { // code here…}Now that you’ve created an async function, we can make use of the await keyword which will pause our code until the Promise has resolved.
  • Here’s how easy that is:async function addAsync(x) { const a = await doubleAfter2Seconds(10); const b = await doubleAfter2Seconds(20); const c = await doubleAfter2Seconds(30); return x + a + b + c;}And here’s the full code:As you can see, we’re still making use of the same doubleAfter2Seconds function.

ES 2017 introduced Asynchronous functions. Async functions are essentially a cleaner way to work with asynchronous code in JavaScript. In order to understand exactly what these are, and how they work…
Continue reading “JavaScript ES 2017: Learn Async/Await by Example – codeburst”

Check out React in Motion today for a steal – 50% off #Reactjs @reactionaryjs

Check out React in Motion today for a steal - 50% off  #Reactjs @reactionaryjs

  • This powerful web framework reinvents the way you create web UI, making it possible to build responsive browser-based applications with flowing, flicker-free screens.
  • The React in Motion liveVideo course gets you up and running with React just as smoothly.
  • As you work through the efficient crystal-clear tutorials from experienced React developer Zac Braddy, you’ll learn the ins and outs of React development, essential techniques for working with reactive applications, and handy code reuse techniques that will save you time and effort!
  • In this liveVideo, you’ll start with the fundamentals of React, as you build your first application.
  • You’ll learn how to set up the perfect build environment, build your own components, make asynchronous calls to third party APIs, efficiently test, debug, and then finally deploy your finished reactive applications!

Continue reading “Check out React in Motion today for a steal – 50% off #Reactjs @reactionaryjs”

Things I wish I knew about Redux — Horrible Hacks — Medium

Things you wish you knew about Redux:  #ReactJS

  • Use reselect sparingly, use props in selectors even more sparingly.
  • If you have a selector that uses props and is shared across multiple components, you will end up with a performance nightmare.
  • Every time I use somebody else’s boilerplate, I would spend hours trying to get it to work.
  • It took a few weeks for me to find somebody else using a “selector” in mapStateToProps .

Read the full article, click here.

@ReactiveConf: “Things you wish you knew about Redux: #ReactJS”

I’ve been working on React/Redux apps for about a year. I wish I knew these things when I started.

Things I wish I knew about Redux — Horrible Hacks — Medium