You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 1-js/11-async/02-promise-basics/article.md
+11-11Lines changed: 11 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -125,7 +125,7 @@ let promise = new Promise(function(resolve, reject) {
125
125
126
126
```smart header="داخلی هستند `result` و `state`"
127
127
.استفاده کنیم. در زیر توضیح داده شدهاند `.then`/`.catch`/`.finally` داخلی هستند. ما نمیتوانیم مستقیماً به آنها دسترسی داشته باشیم. برای این کار میتوانیم از متدهای Promise شیء `result` و `state` ویژگی های
128
-
```
128
+
`````
129
129
130
130
## مصرفکنندگان: then, catch, finally
131
131
@@ -158,43 +158,43 @@ let promise = new Promise(function(resolve, reject) {
158
158
// اجرا می کند resolve را .then اولین تابع در
159
159
promise.then(
160
160
*!*
161
-
result => alert(result), // shows "done!" after 1 second
161
+
result => alert(result), // نشان میدهد "Done!" بعد از 1 ثانیه
162
162
*/!*
163
-
error => alert(error) // doesn't run
163
+
error => alert(error) // اجرا نمیشود
164
164
);
165
165
```
166
166
167
-
The first function was executed.
167
+
اولین تابع اجرا شد.
168
168
169
-
And in the case of a rejection, the second one:
169
+
و در صورت ردشدن دومی:
170
170
171
171
```js run
172
172
let promise = new Promise(function(resolve, reject) {
error => alert(error) // shows "Error: Whoops!" after 1 second
180
+
error => alert(error) // نشان میدهد "Error: Whoops!" بعد از 1 ثانیه
181
181
*/!*
182
182
);
183
183
```
184
184
185
-
If we're interested only in successful completions, then we can provide only one function argument to `.then`:
185
+
اگر فقط به تکمیل موفقیتآمیز علاقه داریم، میتوانیم تنها یک آرگومان تابع را برای `then.` ارائه کنیم:
186
186
187
187
```js run
188
188
let promise = new Promise(resolve => {
189
189
setTimeout(() => resolve("done!"), 1000);
190
190
});
191
191
192
192
*!*
193
-
promise.then(alert); // shows "done!" after 1 second
193
+
promise.then(alert); // نشان میدهد "done!" بعد از 1 ثانیه
194
194
*/!*
195
195
```
196
196
197
-
### catch
197
+
### متدِ catch
198
198
199
199
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:
0 commit comments