Skip to content
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

Allow Promises from lifecycle functions #3000

Closed

Conversation

meiamsome
Copy link
Member

Permits a user to optionally return a Promise from preload, setup and/or draw and will use them to continue when appropriate.

@kjhollen
Copy link
Member

thanks for trying this out, @meiamsome. Promises are a pretty advanced concept for new programmers, who will be reading the documentation for setup, draw, etc. I'd prefer to keep things as simple as possible here, but also understand how this functionality might be useful for testing on the dev side—I'm going to close this for now, but am open to more discussion if you have ideas for how we might get the testing ease without adding complexity to the docs. thanks!

@kjhollen kjhollen closed this Jul 20, 2018
@meiamsome
Copy link
Member Author

@kjhollen This isn't related to testing at all, this is just primarily for ease of use with asynchronous libraries such as tfjs.

For example, I have this test example that uses tfjs to do a large convolution in the draw loop here: source example
Which would be practically impossible from p5 as it currently stands without having to manually implementing the redraw logic inside the sketch.

I do totally accept the want (or even need) for simplicity, though, I just thought that I'd point that out in case it is worth reconsidering on its own merits?

In addition, this only adds a documentation change to redraw that now returns a Promise, but the documentation there already discusses the fact that it is asynchronous (even though it wasn't before, but I digress)

@meiamsome
Copy link
Member Author

@lmccart Given the above - would you please consider re-opening this PR for me? I've been working on #2698 some more today and I really can't see it working in any reasonable way without at least preload being able to return a promise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants