-
Notifications
You must be signed in to change notification settings - Fork 146
Adding documentation Example on how to do parallel loading with Promi… #825
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 2.0
Are you sure you want to change the base?
Conversation
…-main2 Update contributors list
This reverts commit 568a8b8.
Fully unmount sketches that go out of frame
Add libraries, fix bug with old featured ones not getting cycled
FPS library
Hi @Mamatha1718 thank you for putting this together! Because this example is for the 2.0 version and the beta site, please file this PR against the Additionally, please place the .mdx file under cc @perminder-17 - assigning you as reviewer, please feel free to ask for revisions / merge when you feel it's ready. Thanks all! |
// Use async/await with Promise.all to load all three images at once | ||
// This waits untill ALL images are loaded before continuing | ||
[img1, img2, img3] = await Promise.all([ | ||
loadImageAsync('https://picsum.photos/100/100?random=1'), // Replace the image links with user wanted images. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the detailed documentation here! Could you explain the logic a bit more behind the helper loadImageAsync
please? I tried the example and loadImage
here works just as well, and the helper function does not actually have any other params - if you had another idea with this, please let me know, but if it's ok with you, I'd suggest the shorter example with only loadImage
here.
textSize(18); | ||
|
||
// Use async/await with Promise.all to load all three images at once | ||
// This waits untill ALL images are loaded before continuing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor/spelling: "untill" -> "until"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @Mamatha1718 , Really thanks for working on this. Your contributions really matters and are really appreciated. Just requesting a minor changes, as @ksen0 said:
Could you please retarget your PR to the 2.0
branch and re-base your work on top of it?
Steps:
- In the PR, click Edit ➜ change the base from
main
to2.0
➜ Save (Already I did)
Locally:
git fetch origin
git checkout example
git rebase origin/2.0
git push --force-with-lease
This will make the PR show only your intended changes against 2.0
, with conflicts resolved. Thanks!
Added New Example: Parallel Loading with
Promise.all
Adding a new example demonstrating how to use
Promise.all
with asynchronous functions in p5.js.Solve Issue #7674
JavaScript File (
.js
):Implements
Promise.all
to load multiple assets in parallel and display the result after all are resolved.Description File (
.mdx
):Explains the concept of
Promise.all
.Thumbnail image:
16_Async_Await_PromiseAll-thumbnail.png
added tosrc/content/examples/images/featured/
.