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
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,7 +14,7 @@
14
14
15
15
این تشبیه خیلی دقیق نیست، زیرا وعدههای (promises) جاوااسکریپت پیچیدهتر از یک لیست اشتراک ساده است: آنها دارای ویژگیها و محدودیتهای اضافی هستند. اما برای شروع خوب است.
16
16
17
-
نحوِ (syntax) سازنده برای یک شیء وعده(promise) به صورت زیر است:
17
+
سینتکس سازنده برای یک شیء وعده(promise) به صورت زیر است:
18
18
19
19
```js
20
20
let promise =newPromise(function(resolve, reject) {
@@ -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
@@ -135,7 +135,7 @@ let promise = new Promise(function(resolve, reject) {
135
135
136
136
مهم ترین و اساسی ترین آن `then.` است.
137
137
138
-
نحو(syntax) عبارت است از:
138
+
سینتکس عبارت است از:
139
139
140
140
```js
141
141
promise.then(
@@ -148,14 +148,14 @@ promise.then(
148
148
149
149
آرگومان دوم `then.` تابعی است که با رد شدن(rejected) وعده(promise) اجرا میشود و خطا را دریافت میکند.
150
150
151
-
For instance, here's a reaction to a successfully resolved promise:
151
+
به عنوان مثال، در اینجا یک واکنش به یک وعدهی(promise) با موفقیت حل شده(resolved) داریم:
152
152
153
153
```js run
154
154
let promise = new Promise(function(resolve, reject) {
155
155
setTimeout(() => resolve("done!"), 1000);
156
156
});
157
157
158
-
// resolve runs the first function in .then
158
+
// اجرا می کند resolve را .then اولین تابع در
159
159
promise.then(
160
160
*!*
161
161
result => alert(result), // shows "done!" after 1 second
0 commit comments