Hey! I'm YCMJason, a Software Engineer in London 👨💻. Love diving into tech puzzles and sharing them! 🧩
All views expressed here are my own opinions, so please take them with a pinch of salt! 🧂
Hey! I'm YCMJason, a Software Engineer in London 👨💻. Love diving into tech puzzles and sharing them! 🧩
All views expressed here are my own opinions, so please take them with a pinch of salt! 🧂
Hey! I'm YCMJason, a Software Engineer in London 👨💻. Love diving into tech puzzles and sharing them! 🧩
All views expressed here are my own opinions, so please take them with a pinch of salt! 🧂
I guess I wanted to do this in the Redundant promise section, but somehow forgot. And I haven't really remove any promise from that section. Thank you for telling me! I am very glad! <3
Hey! I'm YCMJason, a Software Engineer in London 👨💻. Love diving into tech puzzles and sharing them! 🧩
All views expressed here are my own opinions, so please take them with a pinch of salt! 🧂
It's great! But you haven't really updated the code everywhere, so maybe you should explain why you made it this way (or simplify the rest of the code), because this behavior might not be obvious for those who don't (yet) master the art of Promise ;)
Hey! I'm YCMJason, a Software Engineer in London 👨💻. Love diving into tech puzzles and sharing them! 🧩
All views expressed here are my own opinions, so please take them with a pinch of salt! 🧂
Hey! I'm YCMJason, a Software Engineer in London 👨💻. Love diving into tech puzzles and sharing them! 🧩
All views expressed here are my own opinions, so please take them with a pinch of salt! 🧂
But I guess I wouldn't worry so much about it. I think my aim is for people to understand. So I will leave it this way, it is probably easier to understand.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Neat implementation, though I wonder if there isn't a way to not create a specific
Promise
to simplify the code.Something like this maybe (not tested at all):
From what I remember, by catching errors, you can change the way a Promise resolves or rejects (or was that only with polyfill libs such as
Q
?).You are quite right! Let me make some changes! Cheers!
I don't know if I am right, I didn't test it, but I believe every first iteration of any code (including mine, obviously), can be improved. :)
Well, I just checked it and it says clearly on here.
developer.mozilla.org/en-US/docs/W...
The Promise returned by catch() is rejected if onRejected throws an error or returns a Promise which is itself rejected; otherwise, it is resolved.
I guess I wanted to do this in the
Redundant promise
section, but somehow forgot. And I haven't really remove any promise from that section. Thank you for telling me! I am very glad! <3Glad I could help! ;)
I have added some changes. Tell me if it looks good? :D
It's great! But you haven't really updated the code everywhere, so maybe you should explain why you made it this way (or simplify the rest of the code), because this behavior might not be obvious for those who don't (yet) master the art of Promise ;)
Have I not changed the code? I thought I changed it all?
I added some explanation on how you can resolve a promise in catch.
I still see a lot of
return new Promise()
code along the first half of the article. But I guess it makes sens if you explain it later.I just hope people won't copy & paste without reading a bit further to get the short version. :)
Haha, I see what you mean.
But I guess I wouldn't worry so much about it. I think my aim is for people to understand. So I will leave it this way, it is probably easier to understand.