Skip to content

Commit 0fae38d

Browse files
authored
catch method
1 parent 161c6d9 commit 0fae38d

1 file changed

Lines changed: 11 additions & 11 deletions

File tree

1-js/11-async/02-promise-basics/article.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ let promise = new Promise(function(resolve, reject) {
125125
126126
```smart header="داخلی هستند `result` و `state`"
127127
.استفاده کنیم. در زیر توضیح داده شده‌اند `.then`/`.catch`/`.finally` داخلی هستند. ما نمی‌توانیم مستقیماً به آن‌ها دسترسی داشته باشیم. برای این کار می‌توانیم از متدهای Promise شیء `result` و `state` ویژگی های
128-
```
128+
`````
129129
130130
## مصرف‌کنندگان: then, catch, finally
131131
@@ -158,43 +158,43 @@ let promise = new Promise(function(resolve, reject) {
158158
// اجرا می کند resolve را .then اولین تابع در
159159
promise.then(
160160
*!*
161-
result => alert(result), // shows "done!" after 1 second
161+
result => alert(result), // نشان می‌دهد "Done!" بعد از 1 ثانیه
162162
*/!*
163-
error => alert(error) // doesn't run
163+
error => alert(error) // اجرا نمی‌شود
164164
);
165165
```
166166
167-
The first function was executed.
167+
اولین تابع اجرا شد.
168168
169-
And in the case of a rejection, the second one:
169+
و در صورت ردشدن دومی:
170170
171171
```js run
172172
let promise = new Promise(function(resolve, reject) {
173173
setTimeout(() => reject(new Error("Whoops!")), 1000);
174174
});
175175
176-
// reject runs the second function in .then
176+
// اجرا می کند .then تابع دوم را در reject
177177
promise.then(
178-
result => alert(result), // doesn't run
178+
result => alert(result), // اجرا نمی‌شود
179179
*!*
180-
error => alert(error) // shows "Error: Whoops!" after 1 second
180+
error => alert(error) // نشان می‌دهد "Error: Whoops!" بعد از 1 ثانیه
181181
*/!*
182182
);
183183
```
184184
185-
If we're interested only in successful completions, then we can provide only one function argument to `.then`:
185+
اگر فقط به تکمیل موفقیت‌آمیز علاقه داریم، می‌توانیم تنها یک آرگومان تابع را برای `then.` ارائه کنیم:
186186
187187
```js run
188188
let promise = new Promise(resolve => {
189189
setTimeout(() => resolve("done!"), 1000);
190190
});
191191
192192
*!*
193-
promise.then(alert); // shows "done!" after 1 second
193+
promise.then(alert); // نشان می‌دهد "done!" بعد از 1 ثانیه
194194
*/!*
195195
```
196196
197-
### catch
197+
### متدِ catch
198198
199199
If we're interested only in errors, then we can use `null` as the first argument: `.then(null, errorHandlingFunction)`. Or we can use `.catch(errorHandlingFunction)`, which is exactly the same:
200200

0 commit comments

Comments
 (0)