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

New principle: A Promise represents completion or a value, not a callback (#342) #496

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

jan-ivar
Copy link
Contributor

@jan-ivar jan-ivar commented Jun 3, 2024

Fixes #342.


Preview | Diff

index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
Copy link
Contributor

@martinthomson martinthomson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This LGTM. Time to ask the rest of the TAG to review.

@jan-ivar
Copy link
Contributor Author

Thanks @martinthomson!

I appear to be unable to add reviewers in this repo, so hopefully there's a process for that?

index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
Copy link
Member

@LeaVerou LeaVerou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall this seems a bit esoteric, and I agree with @jyasskin that the title as stated is not always true. I think the examples need some work to establish what should or shouldn't be done, otherwise this principle only makes sense to those who already understand it.

@jan-ivar
Copy link
Contributor Author

Feedback incorporated. Thanks!

@jan-ivar jan-ivar requested a review from LeaVerou July 19, 2024 00:01
@jan-ivar jan-ivar changed the title New principle: A Promise represents a value, not a callback (#342) New principle: A Promise represents completion or a value, not a callback (#342) Jul 23, 2024
@jan-ivar
Copy link
Contributor Author

We could also shorten it further to: "A Promise represents completion, not a callback" — thoughts?

index.bs Outdated Show resolved Hide resolved
Co-authored-by: Harald Alvestrand <[email protected]>
Copy link
Contributor

@martinthomson martinthomson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this. I think that the one thing that might be added

If an API depends on setting up temporary conditions then invoking the caller,
that is a good reason to use a callback rather than a promise.

@jan-ivar
Copy link
Contributor Author

jan-ivar commented Sep 6, 2024

@LeaVerou does this look better?

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.

New principle: Support common promise practices
5 participants