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

JSPromise(resolver:) usage #156

Closed
mhavu opened this issue Jan 27, 2022 · 3 comments · Fixed by #159
Closed

JSPromise(resolver:) usage #156

mhavu opened this issue Jan 27, 2022 · 3 comments · Fixed by #159
Assignees

Comments

@mhavu
Copy link

mhavu commented Jan 27, 2022

Could somebody provide an example of how to use JSPromise(resolver:)? I'm having hard time decoding the following comment in the source code:

Creates a new JSPromise instance from a given resolver closure. resolver takes two closure that your code should call to either resolve or reject this JSPromise instance.

@mhavu mhavu closed this as completed Jan 28, 2022
@mhavu mhavu reopened this Jan 28, 2022
@j-f1
Copy link
Member

j-f1 commented Jan 28, 2022

Those docs look to be outdated. (if you could open a PR to clarify them that would be awesome!) You’re actually passed one callback closure that takes a Result type. If you pass it a .success(...) value, the promise will resolve with that value. If you pass it a .failure(...) value, the promise will reject with that error.

@mhavu
Copy link
Author

mhavu commented Jan 28, 2022

Thanks! I'll open a PR once I get this project out of the way.

@j-f1 j-f1 self-assigned this Jan 28, 2022
@j-f1
Copy link
Member

j-f1 commented Jan 28, 2022

Going to make a couple other improvements to the JSPromise docs so will handle this myself :)

@j-f1 j-f1 mentioned this issue Feb 3, 2022
1 task
@j-f1 j-f1 closed this as completed in #159 Jun 5, 2022
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 a pull request may close this issue.

2 participants