Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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`.
La salida es: `1`.

The second call to `resolve` is ignored, because only the first call of `reject/resolve` is taken into account. Further calls are ignored.
La segunda llamada a 'resolve' se ignora, porque solo se tiene en cuenta la primera llamada de 'reject/resolve'. Otras llamadas son ignoradas.
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?
# ¿Volver a resolver una promesa?


What's the output of the code below?
¿Cuál es el resultado del código a continuación?

```js
let promise = new Promise(function(resolve, reject) {
Expand Down
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
# Demora con una promesa

The built-in function `setTimeout` uses callbacks. Create a promise-based alternative.
La función incorporada `setTimeout` utiliza callbacks. Crea una alternativa basada en promesas.

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:
La función `delay(ms)` debería devolver una promesa. Esa promesa debería resolverse después de `ms` milisegundos, para que podamos agregarle `.then`, así:

```js
function delay(ms) {
// your code
// tu código
}

delay(3000).then(() => alert('runs after 3 seconds'));
delay(3000).then(() => alert('se ejecuta despues de 3 segundos'));
```
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()">Haz clic</button>

<script>

function go() {
showCircle(150, 150, 100).then(div => {
div.classList.add('message-ball');
div.append("Hello, world!");
div.append("Hola, mundo!");
});
}

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

# Animated circle with promise
# Círculo animado con promesa

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.
Vuelva a escribir la función `showCircle` en la solución de la tarea <info:task/animate-circle-callback> para que devuelva una promesa en lugar de aceptar un callback.

The new usage:
Nueva forma de uso:

```js
showCircle(150, 150, 100).then(div => {
div.classList.add('message-ball');
div.append("Hello, world!");
div.append("Hola, mundo!");
});
```

Take the solution of the task <info:task/animate-circle-callback> as the base.
Tome la solución de la tarea <info:task/animate-circle-callback> como base.
248 changes: 124 additions & 124 deletions 1-js/11-async/02-promise-basics/article.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion 1-js/11-async/02-promise-basics/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
script.src = src;

script.onload = () => resolve(script);
script.onerror = () => reject(new Error("Script load error: " + src));
script.onerror = () => reject(new Error("Error de carga de script: " + src));

document.head.append(script);
});
Expand Down