News for hackers. Stuff that matters.
Re:ES6: The features I'm most excited about by AgentME on Sunday July 05, 2015 @10:03PM (#9836235)
There is a way to reject it in the .then() callback. You just throw.
Re:ES6: The features I'm most excited about by haberman on Sunday July 05, 2015 @10:15PM (#9836290)
So in the first function you call reject, but in the second function you throw? I don't love the asymmetry.

Also how do you return a value from the second callback? Just return?

If throw and return work that way for then() functions, why not the same for the initial function?

Re:ES6: The features I'm most excited about by jkrems on Sunday July 05, 2015 @11:01PM (#9836483)
Because the initial one is where you'd interface (potentially) with non-promise code. E.g. in order to wrap a node-style function, you can't throw or return. But in general you shouldn't need to use `new Promise()`, that should in most cases be reserved to more general, low-level code (e.g. a promisify implementation).
Re:ES6: The features I'm most excited about by haberman on Sunday July 05, 2015 @11:25PM (#9836563)
I'm writing code against indexedDB (which doesn't use promises), but I want to expose promises to my callers. So I'm wrapping my indexedDB usage in Promises.

Also some of indexedDB doesn't seem like it would fit with promises, since some operations have 3 or more callbacks (onsuccess, onerror, onupgradeneeded).

Re:ES6: The features I'm most excited about by jbergens on Monday July 06, 2015 @04:37AM (#9837648)
There are a number of IndexedDb libraries that uses promises. However, there is or was a problem with how IndexedDb is specified to work that is not really compatible with promises. I'm not sure if they have fixed this yet. https://github.com/promises-aplus/promises-spec/issues/45#is...
Re:ES6: The features I'm most excited about by haberman on Monday July 06, 2015 @12:07PM (#9840110)
Interesting info, thanks for the pointer!

I can see the benefits of the indexedDb behavior: an open transaction is an exclusive resource, so leaving one dangling locks out other transactions. The auto-commit behavior means it's a lot harder to accidentally leave a transaction dangling. But it is unfortunate that this makes it not play nicely with promises.

Re:ES6: The features I'm most excited about by Bahamut on Sunday July 05, 2015 @11:09PM (#9836514)
Or better, Promise.reject
Re:ES6: The features I'm most excited about by loganfsmyth on Monday July 06, 2015 @02:01AM (#9837061)
Both are useful, but I'd hesitate to call it better. What makes you say it is better?
Re:ES6: The features I'm most excited about by Bahamut on Monday July 06, 2015 @03:18AM (#9837348)
It makes explicit that the intention that a promise should be rejected, as opposed to a throw where one might reasonably expect an exception of some sort.