Skip to content

Commit bb40dae

Browse files
authored
Merge pull request #194 from otmon76/1.11.3
Promises chaining
2 parents 8d38743 + e003333 commit bb40dae

File tree

11 files changed

+213
-213
lines changed

11 files changed

+213
-213
lines changed
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
The short answer is: **no, they are not equal**:
1+
Stručná odpověď zní: **ne, nejsou ekvivalentní**:
22

3-
The difference is that if an error happens in `f1`, then it is handled by `.catch` here:
3+
Rozdíl je v tom, že pokud ve `f1` nastane chyba, je zde ošetřena funkcí `.catch`:
44

55
```js run
6-
promise
6+
příslib
77
.then(f1)
88
.catch(f2);
99
```
1010

11-
...But not here:
11+
...Ale zde ne:
1212

1313
```js run
14-
promise
14+
příslib
1515
.then(f1, f2);
1616
```
1717

18-
That's because an error is passed down the chain, and in the second code piece there's no chain below `f1`.
18+
Je to proto, že chyba je předána řetězem, ale ve druhém uvedeném kódu za `f1` žádný řetěz není.
1919

20-
In other words, `.then` passes results/errors to the next `.then/catch`. So in the first example, there's a `catch` below, and in the second one there isn't, so the error is unhandled.
20+
Jinými slovy, `.then` předá výsledky nebo chyby dalšímu `.then/catch`. V prvním příkladu je za ním `catch`, ale ve druhém není, takže chyba zůstane neošetřena.
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
# Promise: then versus catch
1+
# Příslib: then oproti catch
22

3-
Are these code fragments equal? In other words, do they behave the same way in any circumstances, for any handler functions?
3+
Jsou tyto fragmenty kódu ekvivalentní? Jinými slovy, chovají se zcela stejně za každých okolností a pro jakékoli handlery?
44

55
```js
6-
promise.then(f1).catch(f2);
6+
příslib.then(f1).catch(f2);
77
```
88

9-
Versus:
9+
Oproti:
1010

1111
```js
12-
promise.then(f1, f2);
12+
příslib.then(f1, f2);
1313
```

1-js/11-async/03-promise-chaining/article.md

Lines changed: 187 additions & 187 deletions
Large diffs are not rendered by default.

1-js/11-async/03-promise-chaining/head.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<script>
2-
function loadScript(src) {
2+
function načtiSkript(src) {
33
return new Promise(function(resolve, reject) {
4-
let script = document.createElement('script');
5-
script.src = src;
4+
let skript = document.createElement('script');
5+
skript.src = src;
66

7-
script.onload = () => resolve(script);
8-
script.onerror = () => reject(new Error("Script load error: " + src));
7+
skript.onload = () => resolve(skript);
8+
skript.onerror = () => reject(new Error("Chyba při načítání skriptu: " + src));
99

10-
document.head.append(script);
10+
document.head.append(skript);
1111
});
1212
}
1313
</script>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
function one() {
1+
function jedna() {
22
alert(1);
33
}
Lines changed: 1 addition & 1 deletion
Loading

0 commit comments

Comments
 (0)