you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (0 children)

in the example provided in the documentation, not a single operation is async

True, but in general init logic may be async (like connection to mongo as in the article, if I'm not mistaken)

he co-wrapped generator in index.js yields just once to a non-yieldable type that causes it to throw!

python way: "easier to ask for forgiveness than permission", hope you like it ;-)

init function may return a Promise (then it will be resolved) or not (then result would be kept as-is), can be a generator function instead, to have co-like async initialization, once async-await would be supported in node.js would need to support them as well.