Visitar URL original
Promise by didostap · Pull Request #160 · javascript-tutorial/uk.javascript.info · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

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
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@

# Re-resolve a promise?
# Чи можливо "перевиконати" проміс?


What's the output of the code below?
Що виведе код нижче?

```js
let promise = new Promise(function(resolve, reject) {
Expand Down
4 changes: 2 additions & 2 deletions 1-js/11-async/02-promise-basics/02-delay-promise/solution.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ function delay(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}

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

Please note that in this task `resolve` is called without arguments. We don't return any value from `delay`, just ensure the delay.
Зауважте що `resolve` викликається без аргументів. Ми нічого не повертаємо з `delay`, просто гарантуємо затримку.
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
# Затримка на промісах

The built-in function `setTimeout` uses callbacks. Create a promise-based alternative.
Вбудована функція `setTimeout` використовує колбек-функції. Створіть альтернативу яка базується на промісах.

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)` повинна повертати проміс, який перейде в стан `resolved` через `ms` мілісекунд, так щоб ми могли додати до нього `.then`:

```js
function delay(ms) {
// your code
// ваш код
}

delay(3000).then(() => alert('runs after 3 seconds'));
delay(3000).then(() => alert('виконалось через 3 секунди'));
```
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@

<body>

<button onclick="go()">Click me</button>
<button onclick="go()">Клацни на мене</button>

<script>

function go() {
showCircle(150, 150, 100).then(div => {
div.classList.add('message-ball');
div.append("Hello, world!");
div.append("Привіт, світ!");
});
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@

# Animated circle with 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> таким чином щоб вона повертала проміс, замість того щоб приймати в аргументи колбек-функцію.

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>.
Loading