Skip to content

Commit d454310

Browse files
committed
Improve promises section
1 parent d383bc4 commit d454310

File tree

1 file changed

+14
-6
lines changed
  • apps/components_guide_web/lib/components_guide_web/templates/web_standards

1 file changed

+14
-6
lines changed

apps/components_guide_web/lib/components_guide_web/templates/web_standards/promise.html.md

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,19 @@ promisedValue.then(console.log);
2626
promisedValue.then(console.log);
2727
```
2828

29-
How many times will we see _Creating value_ logged?
29+
Any how many times will we see _Creating value_ logged here?
30+
31+
In both cases, we will see it logged only once, because promises are created eagerly.
32+
33+
Listening to a promise using `.then()` does not affect nor start that promise.
3034

31-
We will see it logged only once, because promises are created eagerly. Listening to a promise using `.then()` does not affect nor start the source promise.
35+
Once a promise has been created, then you may wait to hear its result one time, fifteen times, or not at all, and the original promise will behave the same.
3236

33-
Once a promise has been created, then you may wait to hear its result zero times, one time, or fifteen times, and the original promise will behave the same.
37+
This may seem like a strange limitation, but it simplifies reasoning about promises as they work similar to _values_.
3438

35-
If we have a value in a variable, we feel comfortable knowing that the reading of that variable has no effect on its value.
39+
### How values work
40+
41+
If we store a value in a variable, we feel comfortable knowing that the reading of that variable has absolutely no effect on its value.
3642

3743
```js
3844
const value = 40 + 2;
@@ -42,6 +48,8 @@ console.log(value);
4248
console.log(value);
4349
```
4450

45-
42 will be logged three times, but if removed the logs altogether, the value will remain the same. The act of logging had no effect on the source value. Promises work exactly the same.
51+
42 will be logged three times, but if removed the logs altogether, the value will remain the same. The act of logging had no effect on the source value.
52+
53+
Promises work exactly the same.
4654

47-
We can use this to our advantage, by thinking about promises in the same way we think about values.
55+
We can use this to our advantage, by thinking about promises in the same way we think about values.

0 commit comments

Comments
 (0)