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
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -60,28 +60,28 @@ let promise = new Promise(function(resolve, reject) {
60
60
۱. اجراکننده به صورت خودکار و بلافاصله فراخوانی میشود (توسط `new Promise`).<br />
61
61
۲. اجراکننده دو آرگومان دریافت میکند: `resolve` و `reject`. این توابع توسط موتور جاوااسکریپت از پیش تعریف شدهاند, بنابراین ما نیازی به ایجاد آنها نداریم. وقتی آماده شدیم فقط باید یکی از آنها را فراخوانی کنیم.
62
62
63
-
After one second of "processing" the executor calls `resolve("done")` to produce the result. This changes the state of the `promise` object:
63
+
:را تغییر میدهد `promise` را برای ایجاد نتیجه فراخوانی میکند. این وضعیت شیء `resolve("done")` پس از یک ثانیه "پردازش"، اجراکننده
64
64
65
65

66
66
67
-
That was an example of a successful job completion, a "fulfilled promise".
67
+
این نمونهای از تکمیل موفقیت آمیز کار بود، یک "fulfilled promise".
68
68
69
-
And now an example of the executor rejecting the promise with an error:
69
+
و حال نمونهای از ردشدن(rejecting) وعدهی(promise) اجراکننده با یک خطا:
70
70
71
71
```js
72
72
let promise =newPromise(function(resolve, reject) {
73
-
//after 1 second signal that the job is finished with an error
73
+
//بعد از 1 ثانیه سیگنال میدهد که کار با یک خطا تمام شده است
The call to `reject(...)` moves the promise object to `"rejected"`state:
78
+
فراخوانیِ `(...)reject` شیء وعده(promise) را به وضعیت `"rejected"`میبرد:
79
79
80
80

81
81
82
-
To summarize, the executor should perform a job (usually something that takes time) and then call `resolve`or`reject`to change the state of the corresponding promise object.
82
+
به طور خلاصه، اجراکننده باید یک کار را انجام دهد (معمولاً کاری که زمان میبرد) و سپس `resolve`یا`reject`را برای تغییر وضعیت شیء وعدهی(promise) مربوطه فراخوانی کند.
83
83
84
-
A promise that is either resolved or rejected is called "settled", as opposed to an initially "pending" promise.
84
+
به وعدهای که یا حلوفصل(resolved) میشود یا رد(rejected) میشود، "تسویهشده" ("settled") میگویند، برخلاف وعدهای(promise) که در ابتدا "درحال انتظار" ("pending") است.
85
85
86
86
````smart header="There can be only a single result or an error"
87
87
The executor should call only one `resolve` or one `reject`. Any state change is final.
0 commit comments