Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Promises chaining#259

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
The short answer is: **no, they are not equal**:
Коротка відповідь: **ні, вони не рівні**:

The difference is that if an error happens in `f1`,then it is handled by`.catch`here:
Різниця полягає в тому, що якщо помилка відбувається в `f1`,тоді її обробляє`.catch`тут:

```js run
promise
.then(f1)
.catch(f2);
```

...But not here:
...Але не тут:

```js run
promise
.then(f1, f2);
```

That's because an error is passed down the chain, and in the second code piece there's no chain below `f1`.
Це тому, що помилка передається по ланцюжку, а в другому фрагменті коду немає ланцюжка нижче `f1`.

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.
Іншими словами, `.then`передає результати/помилки наступному`.then/catch`.Отже, у першому прикладі нижче є`catch`, а в другому його немає, тому помилка не оброблена.
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
#Promise: thenversus catch
#Проміс: thenпроти catch

Are these code fragments equal? In other words, do they behave the same way in any circumstances, for any handler functions?
Чи рівні ці фрагменти коду? Іншими словами, чи поводяться вони однаково за будь-яких обставин для будь-яких функцій обробника?

```js
promise.then(f1).catch(f2);
```

Versus:
Проти:

```js
promise.then(f1, f2);
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp