Skip to content

docs: clarify Promise.all execution behavior in part4b#4302

Open
jurajkapsz wants to merge 1 commit into
fullstack-hy2020:sourcefrom
jurajkapsz:patch-4
Open

docs: clarify Promise.all execution behavior in part4b#4302
jurajkapsz wants to merge 1 commit into
fullstack-hy2020:sourcefrom
jurajkapsz:patch-4

Conversation

@jurajkapsz

Copy link
Copy Markdown
  • This update tries to clarify that Promise.all waits for promises to settle rather than executing them, as promises are already running when they are passed to Promise.all (although "settle" might be a new term for students).
  • Also clarify that sequential execution is achieved by using await inside a for...of loop, not by merely creating or handling promises inside the loop, such as:
for (const note of helper.initialNotes) {
  new Note(note).save().then(() => {
    // handle success
  });
}

- This update tries to clarify that `Promise.all` **waits for promises to settle** rather than executing them, as promises are already running when they are passed to `Promise.all`.
- Also clarify that sequential execution is achieved by using `await` inside a `for...of` loop, not by merely creating or handling promises inside the loop, such as:

```js
for (const note of helper.initialNotes) {
  new Note(note).save().then(() => {
    // handle success
  });
}
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant