Skip to content

Commit 1403eba

Browse files
committed
add missing g.next() call
1 parent b3da218 commit 1403eba

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

ch04.asciidoc

+2-1
Original file line numberDiff line numberDiff line change
@@ -1905,6 +1905,7 @@ Let's look at a similar example, but this time we'll be using generators. The fo
19051905
----
19061906
function getRandomArticle(gen) {
19071907
const g = gen()
1908+
g.next() // advance the generator to the first yield expression
19081909
fetch('/articles/random', {
19091910
headers: new Headers({
19101911
Accept: 'application/json'
@@ -2124,7 +2125,7 @@ function spawn(generator) {
21242125
resolve(next.value)
21252126
return
21262127
}
2127-
// not finished, chain off the yielded promise
2128+
// not finished, chain off the yielded promise
21282129
// and run next step
21292130
Promise
21302131
.resolve(next.value)

0 commit comments

Comments
 (0)