-
Notifications
You must be signed in to change notification settings - Fork 4
Description
Some addons made for p5 v1, like p5play, need "init" hooks or equivalent functionality: getting access to the instance of p5 and being able to add to it before preload runs, as discussed in this feature request: processing/p5.js#7742.
In conclusion though, it's fair to say that "init" lifecycle hooks only have the potential to be useful if an addon relies on the preload.js compatibility addon, so its more appropriate that similar functionality be added to it instead of p5 v2.
@ksen0 My workaround of including and making custom modifications to the preload.js compat addon in p5play to achieve this is hacky and shouldn't be encouraged, since it could easily result in addons being incompatible with one another as pointed out by Limzy.
processing/p5.js#7798 (comment)
EDIT: You can see what I'm currently doing here:
https://github.com/quinton-ashley/p5play/blob/48342bae3594a0703f24d1bbc07346ee45b185d3/p5play.js#L10975
@davepagurek came up with a good related feature, but it doesn't fix this issue.
processing/p5.js#7797
I'm thinking preload.js could include a p5.registerInitMethod
or p5.registerInitHook
function.
And then init hooks would run before preload is run within the "presetup" hook in preload.js.
I can make a PR if desired!