Skip to content

Commit b548886

Browse files
authored
let's
1 parent 4cf1b49 commit b548886

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
@@ -245,10 +245,10 @@ new Promise((resolve, reject) => {
245245
setTimeout(() => resolve("result"), 2000)
246246
})
247247
.finally(() => alert("Promise ready"))
248-
.then(result => alert(result)); // <-- .then handles the result
248+
.then(result => alert(result)); // <-- نتیجه را اجرا می‌کند .then
249249
```
250250
251-
And here there's an error in the promise, passed through `finally` to `catch`:
251+
:پاس داده می‌شود `catch` به `finally` و در اینجا یک خطایی در وعده وجود دارد که از
252252
253253
```js run
254254
new Promise((resolve, reject) => {
@@ -258,27 +258,27 @@ new Promise((resolve, reject) => {
258258
.catch(err => alert(err)); // <-- .catch handles the error object
259259
```
260260
261-
That's very convenient, because `finally` is not meant to process a promise result. So it passes it through.
261+
این بسیار راحت است، زیرا `finally` به معنای پردازش یک نتیجه وعده(promise) نیست. بنابراین از آن عبور می‌کند.
262262
263-
We'll talk more about promise chaining and result-passing between handlers in the next chapter.
263+
در فصل بعدی بیشتر در مورد زنجیره وعده(promise) و انتقال نتیجه بین اجراکنندگان صحبت خواهیم کرد.
264264
265265
266-
````smart header="We can attach handlers to settled promises"
267-
If a promise is pending, `.then/catch/finally` handlers wait for it. Otherwise, if a promise has already settled, they just run:
266+
````smart header="ما می توانیم اجراکننده‌ها را به وعده‌های تسویه‌شده متصل کنیم"
267+
اگر وعده‌ای در حال تعلیق است، اجراکنندگان `then/catch/finally.` منتظر آن هستند. در غیر این صورت، اگر وعده‌ای قبلاً تسویه شده باشد، آنها فقط اجرا می کنند:
268268
269269
```js run
270-
// the promise becomes resolved immediately upon creation
270+
// وعده بلافاصله پس از ایجاد حل‌وفصل می‌شود
271271
let promise = new Promise(resolve => resolve("done!"));
272272
273-
promise.then(alert); // done! (shows up right now)
273+
promise.then(alert); // done! (همین الآن نشان می‌دهد)
274274
```
275275
276-
Note that this makes promises more powerful than the real life "subscription list" scenario. If the singer has already released their song and then a person signs up on the subscription list, they probably won't receive that song. Subscriptions in real life must be done prior to the event.
276+
توجه داشته باشید که این باعث می‌شود وعده‌ها قدرتمندتر از سناریوی واقعی "فهرست اشتراک" باشد. اگر خواننده قبلا آهنگ خود را منتشر کرده باشد و سپس شخصی در لیست اشتراک ثبت نام کند، احتمالاً آن آهنگ را دریافت نخواهد کرد. اشتراک در دنیای واقعی باید قبل از رویداد انجام شود.
277277
278-
Promises are more flexible. We can add handlers any time: if the result is already there, they just execute.
278+
وعده‌ها انعطاف‌پذیرتر هستند. ما می توانیم هر زمان که بخواهیم اجراکنندگان را اضافه کنیم: اگر نتیجه از قبل وجود داشته باشد، آنها فقط اجرا می‌شوند.
279279
````
280280

281-
Next, let's see more practical examples of how promises can help us write asynchronous code.
281+
در مرحله بعد، بیایید نمونه‌های عملی بیشتری را ببینیم که چگونه وعده‌ها می‌توانند به ما در نوشتن کد ناهمزمان کمک کنند.
282282

283283
## Example: loadScript [#loadscript]
284284

0 commit comments

Comments
 (0)