Open quinton-ashley opened 2 months ago
@DipakKhade Thanks for the PR! But please comment on an issue before trying to implement a feature though.
The implementation of load(...args)
should use Promise.all
. Also it should be able to load many types of files, not just text and json. It would need to be a function added to instances of Q5 not Q5 itself, in order to access other loading functions.
After examining the p5 feature request again more closely, I'm a bit confused myself about how they plan to support loading images, video, and sounds with this one method. I suppose it could wrap preload functions like loadImage
and loadSound
in a promise. What do you think of that idea?
I also think we need to figure out a way for addon developers to add support to q5 load
for loading additional file types but that could be added after an initial implementation is done.
An async function simply named
load
could be used to load any file or multiple files asynchronously and return a promise.This will be implemented in q5-util.js The q5
setup
function is already async.This idea was suggested by @mattdesl and iterated on by @mvicky2592 in this p5.js issue discussion. I also think keeping the
preload
system for backwards compatibility and ease of use for beginners is the right idea though. https://github.com/processing/p5.js/issues/6767