Skip to content

[p5.js 2.0 Docs] Change in return value for load functions that use callbacks needs to be documented #8280

@sidwellr

Description

@sidwellr

Topic

In version 1.x, the load... functions (loadImage, loadJSON, etc.) always returned the loaded data, whether or not callbacks were used. This changed in version 2: now when load.. functions are used with callbacks, they now return the value returned by the callback instead of the loaded item. This is a nice feature that allows a successCallback to dynamically modify the loaded data. It also allows an errorCallback to return some default data. But this feature needs to be described in the documentation for the various load... functions. The need for this was noted by @limzykenneth in a comment on a previous issue, but it looks like it was missed.

This is a breaking change from version 1 to 2 since most version 1 sketches that use both an assignment and a callback function won't return the desired data from the callback function (this has actually broken one of the examples on the p5.js website; see /processing/p5.js-website#1033), so this should be emphasized in the documentation.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions