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”

Develop React Native iOS apps on Linux – Santiago de León – Medium

Develop React Native #iOS apps on Linux:  #ReactJS #JavaScript

  • Develop React Native iOS apps on LinuxYes, you need a Mac to do any kind of iOS development but that doesn’t mean that you have to write the code in the Mac.
  • You can test this by starting any web server on your dev machine, binding it to that port and trying to reach http://DEV_MACHINE_IP:8585 with a web browser in your Mac.
  • So, I did: I fired up the packager in my dev box with react-native start –host –port 8585 (setting the host to is vital, because otherwise your server will only bind to localhost and won’t be accessible from your Mac).
  • I couldn’t find a setting to tell React Native to poll the packager service in a different host:port pair, so I figured that if I wanted it to access the server running in my dev machine, I had to do a TCP tunnel, which is actually quite easy to set up.
  • You’re all set!Make some changes to your React Native code in your dev machine, then hit Cmd+R in your Mac to see the changes.

Yes, you need a Mac to do any kind of iOS development but that doesn’t mean that you have to write the code in the Mac. You can actually write your code in whatever OS/editor combo you prefer and use…
Continue reading “Develop React Native iOS apps on Linux – Santiago de León – Medium”

lexlewthor / node-react-framework — Bitbucket

  • Pull request #4 merged in lexlewthor/node-react-framework
  • Pull request #4 created in lexlewthor/node-react-framework
  • 8e5a15b Merged in lexlewthor/alewis-web ( pull request #3 )
  • Atlassian SourceTree is a free Git and Mercurial client for Mac.
  • d732925 added non minified browserify script and debug script to build and launch server

Read the full article, click here.

@lexlewis1981: “#opensource @reactjs @nodejs #javascript #web #framework now with @docker support #code examples and scripts!”

lexlewthor / node-react-framework — Bitbucket