You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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)
To be clear on the difference between this and #7797, would this be primarily for backwards compatibility with addons designed for v1? If so, would it be helpful to bring back the p5.prototype.registerMethod() function and support for the old lifecycle states in the compatibility addon so that no code changes would be required in those community libraries?
That could be helpful, as long as it's deemed fit to include in preload.js, if not then no.
But code changes probably would still be required for most p5 v1 addons, including ml5, because preload.js doesn't add _incrementPreload and _decrementPreload functions. (Note that p5.sound does a feature check to see if those functions exist or not.) You can see how I implemented them in q5-core though.
That's a separate issue though, I'm not requesting a higher degree of backwards compatibility other than "init" hook support.
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
orp5.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!
The text was updated successfully, but these errors were encountered: