Skip to content

Revise Promise.all example#1477

Open
ksen0 wants to merge 2 commits into
mainfrom
async_await_example
Open

Revise Promise.all example#1477
ksen0 wants to merge 2 commits into
mainfrom
async_await_example

Conversation

@ksen0

@ksen0 ksen0 commented Jun 30, 2026

Copy link
Copy Markdown
Member

This proposed revision:

  • organizes this example into the existing loading/saving section so it's more discoverable
  • adds a link to @Qianqianye 's recent video
  • attempts to simplify language

Please note that this will break the existing link to this example but these links are not intended as permalinks. Search should be usable to find the correct resource (though right now there is a known problem with it)

Before:

shows the thumbnail in its own section at the bottom of the page shows the current description in context of hte example page

After:

shows the thumbnail in the loading saving data section on examples listing shows the updated desciption

@ksen0 ksen0 force-pushed the async_await_example branch from 7fb5987 to ff60074 Compare June 30, 2026 12:28
@ksen0 ksen0 marked this pull request as ready for review June 30, 2026 12:29
Updated the description to clarify the use of async/await and Promise.all for loading multiple images. Improved the explanation of loading images simultaneously and added a reference to loading fonts.

@perminder-17 perminder-17 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

---

Use [`async/await`](https://beta.p5js.org/reference/p5/async_await/) keywords
together with [`Promise.all()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/all) to loading multiple images together. This can speed up sketch loading, because the images will be loaded at the same time, instead of one after the other. The images are drawn together on the canvas only after they all finish loading.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
together with [`Promise.all()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/all) to loading multiple images together. This can speed up sketch loading, because the images will be loaded at the same time, instead of one after the other. The images are drawn together on the canvas only after they all finish loading.
together with [`Promise.all()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/all) to load multiple images together. This can speed up sketch loading, because the images will be loaded at the same time, instead of one after the other. The images are drawn together on the canvas only after they all finish loading.

@xinemata xinemata left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall this is an excellent update and feels more aligned with the rest of the examples.

featuredImage: "../../../images/featured/16_Async_Await_PromiseAll-thumbnail.png"
featuredImageAlt: Three random images loaded and displayed on a canvas after using async/await and Promise.all.
title: Load Multiple Images with Promise.all
oneLineDescription: Load multiple resources, like images, at the same time with Promise.all.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current one-liner can be less redundant, since Promise.all is already prominently featured in the title.

Possibly "Load multiple files at the same time before drawing on canvas."

"files" feel the least ambiguous to me, but I'm also okay with it being used interchangeably with "assets" or "resources".

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.

4 participants