News for hackers. Stuff that matters.
Re:ES6: The features I'm most excited about by 15155 on Sunday July 05, 2015 @10:01PM (#9836225)
async/await solves error handling and hanging onto values quite nicely.

IMO you should use Babel and take advantage.

Re:ES6: The features I'm most excited about by haberman on Sunday July 05, 2015 @10:18PM (#9836301)
I am using Babel already. Not sure I'm ready to dip into ES7 features though. ES6 feels bleeding-edge enough for me.
Re:ES6: The features I'm most excited about by grandalf on Sunday July 05, 2015 @11:07PM (#9836507)
link to example please
Re:ES6: The features I'm most excited about by 15155 on Monday July 06, 2015 @12:43AM (#9836827)

  async function foo() {
    try {
      const valueOne = await promiseReturningFunction();
      const valueTwo = await anotherAsyncFunction(valueOne);

      return valueTwo;
    } catch (err) {
      alert(err);
    }
  }

  foo(); //Returns a Promise.
----

In this example, I've sequenced the resolution of two promises (async functions return Promises when invoked)

If either of these Promises reject or throw an error, or if any of the code within the try {} block throws an error, the error will be caught inline in the catch block (one area only).

You can also see that both Promise's return values are in-scope and continually usable (vs. losing scope with 'then' chains).

Re:ES6: The features I'm most excited about by grandalf on Monday July 06, 2015 @01:29AM (#9836977)
I see. Not sure what the best practice is for the losing scope in then chains issue with promises. I ended up creating something along the lines of a message object designed for each chain, which felt like a smell.
Re:ES6: The features I'm most excited about by 15155 on Monday July 06, 2015 @02:24AM (#9837142)
Feels like an un-compiler-assisted State monad.

IMO threading an object through is probably the best method, unfortunately. You could use an Immutable Record or something to help keep it under control.

I would personally just use async/await to more explicitly handle the sequencing/binding.

Re:ES6: The features I'm most excited about by grandalf on Monday July 06, 2015 @08:08AM (#9838472)
Agreed. I think I'll refactor... thanks for the example.