IssueRaiser

I've just been playing with Promises and like them a lot.

I've just been playing with Promises and like them a lot. But one thing I find strange is that ".then()" creates a new promise, but with no way to reject it. ie. I can't write: return new Promise((resolve, reject) => { // Do some stuff, call resolve()/reject() on success/failure. }).then((step1Val, resolve, reject) => { // Do some stuff, call resolve()/reject() on success/failure. // But this doesn't actually work, because the "then" callback // doesn't get resolve/reject as args. }); Instead I'm having to write this as the following, which is more verbose: return new Promise((resolve, reject) => { // Do some stuff, call resolve()/reject() on success/failure. }).then(new Promise((resolve, reject) = { // Do some stuff, call resolve()/reject() on success/failure. // But this way I don't get access to step1Val. })); Another bummer of this style is that that the second step doesn't get access to the first step's value.

Posted by haberman on Jul 6, 2015, 1:55 AM

Tags

Related issues

Raise real-world problems, find people facing the same issue, and discuss solutions.5,500 issues0 comments

hackernews (Other)

I've just been playing with Promises and like them a lot.

habermanJul 6, 2015, 1:55 AM

I've just been playing with Promises and like them a lot. But one thing I find strange is that ".then()" creates a new promise, but with no way to reject it. ie. I can't write: return new Promise((resolve, reject) => { // Do some stuff, call resolve()/reject() on success/failure. }).then((step1Val, resolve, reject) => { // Do some stuff, call resolve()/reject() on success/failure. // But this doesn't actually work, because the "then" callback // doesn't get resolve/reject as args. }); Instead I'm having to write this as the following, which is more verbose: return new Promise((resolve, reject) => { // Do some stuff, call resolve()/reject() on success/failure. }).then(new Promise((resolve, reject) = { // Do some stuff, call resolve()/reject() on success/failure. // But this way I don't get access to step1Val. })); Another bummer of this style is that that the second step doesn't get access to the first step's value.

Comments (0)

No comments yet. Start the discussion.

Comment on this issue