Skip to content

Commit d905dbe

Browse files
Merge pull request #200 from nglazov/1-js/11-async/02-promise-basics
1-js/11-async/02-promise-basics
2 parents 2651b4a + 9535675 commit d905dbe

7 files changed

Lines changed: 127 additions & 129 deletions

File tree

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
The output is: `1`.
22

3-
The second call to `resolve` is ignored, because only the first call of `reject/resolve` is taken into account. Further calls are ignored.
3+
Второй вызов `resolve` будет проигнорирован, поскольку учитывается только первый вызов `reject/resolve`. Все последующие вызовы - игнорируются.

1-js/11-async/02-promise-basics/01-re-resolve/task.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11

2-
# Re-resolve a promise?
2+
# Можно ли "перевыполнить" промис?
33

44

5-
What's the output of the code below?
5+
Что выведет код ниже?
66

77
```js
88
let promise = new Promise(function(resolve, reject) {

1-js/11-async/02-promise-basics/02-delay-promise/solution.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ function delay(ms) {
66
delay(3000).then(() => alert('runs after 3 seconds'));
77
```
88

9-
Please note that in this task `resolve` is called without arguments. We don't return any value from `delay`, just ensure the delay.
9+
Заметьте, что `resolve` вызывается без аргументов. Мы не возвращаем из `delay` ничего, просто гарантируем задержку.
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11

2-
# Delay with a promise
2+
# Задержка на промисах
33

4-
The built-in function `setTimeout` uses callbacks. Create a promise-based alternative.
4+
Встроенная функция `setTimeout` использует колбэк-функции. Создайте альтернативу, использующую промисы.
55

6-
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:
6+
Функция `delay(ms)` должна возвращать промис, который перейдёт в состояние "выполнен" через `ms` миллисекунд, так чтобы мы могли добавить к нему `.then`:
77

88
```js
99
function delay(ms) {
10-
// your code
10+
// ваш код
1111
}
1212

13-
delay(3000).then(() => alert('runs after 3 seconds'));
13+
delay(3000).then(() => alert('выполнилось через 3 секунды'));
1414
```

1-js/11-async/02-promise-basics/03-animate-circle-promise/solution.view/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
<body>
2424

25-
<button onclick="go()">Click me</button>
25+
<button onclick="go()">Нажми меня</button>
2626

2727
<script>
2828

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11

22
# Animated circle with promise
33

4-
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.
4+
Перепишите функцию `showCircle`, написанную в задании <info:task/animate-circle-callback> таким образом, чтобы она возвращала промис, вместо того чтобы принимать в аргументы функцию-callback.
55

6-
The new usage:
6+
Новое использование:
77

88
```js
99
showCircle(150, 150, 100).then(div => {
@@ -12,4 +12,4 @@ showCircle(150, 150, 100).then(div => {
1212
});
1313
```
1414

15-
Take the solution of the task <info:task/animate-circle-callback> as the base.
15+
Возьмите решение из <info:task/animate-circle-callback> в качестве основы.

1-js/11-async/02-promise-basics/article.md

Lines changed: 114 additions & 116 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)