Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Promise#160

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
Show all changes
11 commits
Select commitHold shift + click to select a range
7148f00
bromise basics
didostapJul 28, 2021
b283141
Update 1-js/11-async/02-promise-basics/article.md
tarasyyykAug 3, 2021
a639797
Update 1-js/11-async/02-promise-basics/article.md
tarasyyykAug 3, 2021
2fd1075
Update 1-js/11-async/02-promise-basics/article.md
tarasyyykAug 3, 2021
362b34b
Update 1-js/11-async/02-promise-basics/article.md
tarasyyykAug 3, 2021
5c61fe3
Update 1-js/11-async/02-promise-basics/article.md
tarasyyykAug 3, 2021
12d1159
Remove unnecessary line
tarasyyykAug 3, 2021
4461dc1
Update 1-js/11-async/02-promise-basics/03-animate-circle-promise/solu…
tarasyyykAug 3, 2021
68bbd0d
Update 1-js/11-async/02-promise-basics/article.md
tarasyyykAug 3, 2021
ef7b1e8
Update 1-js/11-async/02-promise-basics/article.md
tarasyyykAug 3, 2021
027693e
Correct lines, remove unnecessary lines
tarasyyykAug 3, 2021
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 deletions1-js/11-async/02-promise-basics/01-re-resolve/solution.md
View file
Open in desktop
Original file line numberDiff line numberDiff 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 deletions1-js/11-async/02-promise-basics/01-re-resolve/task.md
View file
Open in desktop
Original file line numberDiff line numberDiff 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
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,7 +3,7 @@ function delay(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}

delay(3000).then(() => alert('runs after 3seconds'));
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 deletions1-js/11-async/02-promise-basics/02-delay-promise/task.md
View file
Open in desktop
Original file line numberDiff line numberDiff 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 3seconds'));
delay(3000).then(() => alert('виконалось через 3секунди'));
```
View file
Open in desktop
Original file line numberDiff line numberDiff 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
View file
Open in desktop
Original file line numberDiff line numberDiff 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

[8]ページ先頭

©2009-2025 Movatter.jp