We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a9d7b19 commit 83f77bbCopy full SHA for 83f77bb
manuscript/10-Promises.md
@@ -771,19 +771,19 @@ function run(taskDef) {
771
// create the iterator
772
let task = taskDef();
773
774
+ // start the task
775
+ let result = task.next();
776
+
777
// recursive function to iterate through
778
(function step() {
779
- let result = task.next(),
- promise;
-
780
// if there's more to do
781
if (!result.done) {
782
783
// resolve to a promise to make it easy
784
- promise = Promise.resolve(result.value);
+ let promise = Promise.resolve(result.value);
785
promise.then(function(value) {
786
- task.next(value);
+ result = task.next(value);
787
step();
788
}).catch(function(error) {
789
task.throw(error);
0 commit comments