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

Optionally support async render functions for JSX pages #84

Merged
merged 2 commits into from May 2, 2021

Conversation

jerluc
Copy link
Contributor

@jerluc jerluc commented May 1, 2021

It looks like engines already support async render functions, so I figured it would make sense to enable this functionality for JSX pages. Note that I'm using await Promise.resolve(...) as according to the MDN docs, this method can both safely wrap an existing Promise or a regular value. This means that this change should remain backward compatible for normal non-async page functions.

engines/jsx.js Outdated Show resolved Hide resolved
@oscarotero
Copy link
Member

oscarotero commented May 2, 2021

Good catch, thanks for this!
I've left a comment to simplify the code :)

Since `await` can already handle non-`Promise` values, we don't need to actually explicitly wrap the result in `Promise.resolve(...)`

Co-authored-by: Oscar Otero <oom@oscarotero.com>
@oscarotero oscarotero merged commit e703467 into lumeland:master May 2, 2021
@oscarotero
Copy link
Member

Thank you 👍

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

Successfully merging this pull request may close these issues.

None yet

2 participants