Understanding JavaScript Promises: The Thunk

preview_player
Показать описание
Understanding promise internals and how they allow us to sequence async events. We look at standard callbacks and then the Thunk which promises are built upon.
Рекомендации по теме
Комментарии
Автор

I still don't know how this Amazing Explanation doesn't have more views...guess not every developer wants to get to Senior🤷‍♂

luisbalza
Автор

This is exactly the same example Kyle Simpson used in FEM, but for some reason I only got it after you explained it.

evenaicantfigurethisout
Автор

excellent shit dude. I'd rename effort to delay and DoSomething to getData but genuinely, this was flawless!

tadiwamahlunge
Автор

Thank you for the demo! Great job. Question, i'm still confused by the last part. Here i would have thought that 'task1' would set fn equal to cb and return null. Then task2 would fire and you would still have the same problem. How are the returned functions blocking in this case?


const task1 = doSomething('task1', 3000);
const task2 = doSomething('task2', 1000);

task1(res => {
console.log(res);
task2((res) => {
console.log(res);
});
});

erbolduran
Автор

Man but we still needed to wrap task2 inside task1. So thunks are still not capable of solving callback hell problem I guess.

AbhishekKumar-hrsr
Автор

can you draw an execution thread, thanks

hishamabonjeim