-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Hook just before global mode instantiation #4204
Comments
@limzykenneth @stalgiag , |
@limzykenneth @stalgiag , |
I'm gauging interest and potential problems of this feature with this issue so I'm not looking for someone in particular to implement this as I have a pretty good idea of how to implement this myself. Thanks for the interest though. PS. It's the holiday period so it may take longer for us to reply to a message, there's no need to ping us again. |
small note that i think some work in #4233 will help set the stage for this infrastructure |
Nature of issue?
Most appropriate sub-area of p5.js?
New feature details:
For addon libraries, is there a hook that will execute before global mode p5 is instantiated? If not can one be added?
The use case is that I'm fiddling around with some async code that when resolve will attach functions to the
p5.prototype
but since it is async the global mode p5 will have instantiated before it is completed so the global mode p5 sketch won't have that function attached yet.I can use instance mode and delay the call to
new p5(sketch)
but for an addon library it should work out of the box, so I'm thinking can an optional hook be added just before global mode is instantiated that the async addon library can call when it is done loading to trigger global mode?One idea comes from
core/init.js
Instead of checking for
readyState
, check for a static function on thep5
object and if it'snull
checkreadyState
as usual, if not wait for it to resolve (assuming it should return a Promise) then run_globalInit()
.The text was updated successfully, but these errors were encountered: