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

Promises basics #3285

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

bogdanbacosca
Copy link
Contributor

Lines 294 and 327 refer to line 84:

A promise that is either resolved or rejected is called "settled"

Lines 227 and 225 just have some potentially good improvements for readability.

"also" or something equivalent would be a good continuation of the "Just like" starting point from the beginning of the sentence. (maybe)
The addition of the word "if" would probably make more sense.
Replaced resolved with settled for consistency.
switched 'resolves' with 'settles' for consistency
@bogdanbacosca bogdanbacosca changed the title Promises basics en Promises basics Nov 29, 2022
Copy link
Contributor

@shallow-beach shallow-beach left a comment

Choose a reason for hiding this comment

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

a few comments


The call `.finally(f)` is similar to `.then(f, f)` in the sense that `f` runs always, when the promise is settled: be it resolve or reject.

The idea of `finally` is to set up a handler for performing cleanup/finalizing after the previous operations are complete.

E.g. stopping loading indicators, closing no longer needed connections, etc.

Think of it as a party finisher. No matter was a party good or bad, how many friends were in it, we still need (or at least should) do a cleanup after it.
Think of it as a party finisher. No matter if a party was good or bad, how many friends were in it, we still need (or at least should) do a cleanup after it.
Copy link
Contributor

Choose a reason for hiding this comment

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

i prefer the solution at #3390

@@ -214,15 +214,15 @@ The call `.catch(f)` is a complete analog of `.then(null, f)`, it's just a short

## Cleanup: finally

Just like there's a `finally` clause in a regular `try {...} catch {...}`, there's `finally` in promises.
Just like there's a `finally` clause in a regular `try {...} catch {...}`, there's a `finally` in promises also.
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe:

Just like there's a finally clause in a regular try {...} catch {...}, there's a finally for promise chains.

@@ -291,7 +291,7 @@ Sometimes, it might be that a promise is already settled when we add a handler t
In such case, these handlers just run immediately:

```js run
// the promise becomes resolved immediately upon creation
// the promise becomes settled immediately upon creation
Copy link
Contributor

Choose a reason for hiding this comment

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

disagree, 'resolve' goes well with use of resolve in the article's examples. Maybe 'fulfilled' if trying to use ECMA term.

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.

2 participants