Promise by Beroozam · Pull Request #197 · javascript-tutorial/fa.javascript.info
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Promise #197
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
5daaa74
promise
Beroozam
a42e936
syntax
Beroozam
f18594f
resolve and reject
Beroozam
db7e505
takes time
Beroozam
79ae48f
calling after ready
Beroozam
0b663d6
resolved
Beroozam
fefe0d7
additional arg
Beroozam
a140d3b
object Error
Beroozam
c84a77a
promise resolved
Beroozam
0d89ed2
handle
Beroozam
161c6d9
runs first function
Beroozam
0fae38d
catch method
Beroozam
8ce413e
finally method
Beroozam
4cf1b49
finally pass
Beroozam
b548886
let's
Beroozam
c0b9e9a
table
Beroozam
41ae6fc
re resolve solution
Beroozam
b3feeb0
re resolve task
Beroozam
8582f9d
delay promise solution
Beroozam
d92e9ee
delay promise task
Beroozam
3e223e9
animate circle promise .html
Beroozam
8bbdb2f
animate circle promise task
Beroozam
8c021fa
delay promise solution2
Beroozam
d40914b
review
Beroozam
ce43fa3
review2
Beroozam
2d1288a
Apply suggestions from code review
Beroozam
3c76446
Apply suggestions from code review
Beroozam
9763d18
Apply suggestions from code review
Beroozam
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions
1-js/11-async/02-promise-basics/01-re-resolve/solution.md
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| The output is: `1`. | ||
| خروجی: `1`. | ||
|
|
||
| The second call to `resolve` is ignored, because only the first call of `reject/resolve` is taken into account. Further calls are ignored. | ||
| فراخوانی دوم برای `resolve` نادیده گرفته میشود، زیرا فقط اولین فراخوانی `reject/resolve` در نظر گرفته میشود. فراخوانیهای بعدی نادیده گرفته میشوند. |
4 changes: 2 additions & 2 deletions
1-js/11-async/02-promise-basics/01-re-resolve/task.md
4 changes: 2 additions & 2 deletions
1-js/11-async/02-promise-basics/02-delay-promise/solution.md
10 changes: 5 additions & 5 deletions
1-js/11-async/02-promise-basics/02-delay-promise/task.md
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,14 @@ | ||
|
|
||
| # Delay with a promise | ||
| # تاخیر با Promise | ||
|
|
||
| The built-in function `setTimeout` uses callbacks. Create a promise-based alternative. | ||
| تابع داخلی `setTimeout` از کالبکها استفاده میکند. یک جایگزین مبتنی بر Promise ایجاد کنید. | ||
|
|
||
| The function `delay(ms)` should return a promise. That promise should resolve after `ms` milliseconds, so that we can add `.then` to it, like this: | ||
| تابع `delay(ms)` باید یک Promise برگرداند. این وعده باید پس از `ms` میلیثانیه حلوفصل (resolve) شود، به طوری که میتوانیم `then.` را به آن اضافه کنیم، مانند این: | ||
|
|
||
| ```js | ||
| function delay(ms) { | ||
| // your code | ||
| // کد شما | ||
| } | ||
|
|
||
| delay(3000).then(() => alert('runs after 3 seconds')); | ||
| delay(3000).then(() => alert('بعد از 3 ثانیه اجرا میشود')); | ||
| ``` |
10 changes: 5 additions & 5 deletions
1-js/11-async/02-promise-basics/03-animate-circle-promise/task.md
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,15 +1,15 @@ | ||
|
|
||
| # Animated circle with promise | ||
| # دایره متحرک با Promise | ||
|
|
||
| Rewrite the `showCircle` function in the solution of the task <info:task/animate-circle-callback> so that it returns a promise instead of accepting a callback. | ||
| تابع `showCircle` را در راهحل تمرین <info:task/animate-circle-callback> بازنویسی کنید تا به جای پذیرش کالبک، یک Promise را برگرداند. | ||
|
|
||
| The new usage: | ||
| کاربرد جدید: | ||
|
|
||
| ```js | ||
| showCircle(150, 150, 100).then(div => { | ||
| div.classList.add('message-ball'); | ||
| div.append("Hello, world!"); | ||
| div.append("سلام دنیا!"); | ||
| }); | ||
| ``` | ||
|
|
||
| Take the solution of the task <info:task/animate-circle-callback> as the base. | ||
| راهحل تمرین <info:task/animate-circle-callback> را به عنوان پایه در نظر بگیرید. |