Promise by diogoosz · Pull Request #465 · javascript-tutorial/pt.javascript.info
Repository navigation
Promise - #465
Merged
gabifs merged 2 commits into javascript-tutorial:master from diogoosz:translate-promise Nov 7, 2026
Merged
Promise #465 gabifs merged 2 commits into javascript-tutorial:master from diogoosz:translate-promise
Conversation
diogoosz commented Nov 4, 2026
Copy link Copy Markdown
Contributor
Tradução do artigo "Promise" para o português, incluindo os três exercícios.
Conforme comentado na #1 .
Translate 'Promise' article to Portuguese
51b642e
CLAassistant commented Nov 4, 2026 · edited Loading
Copy link Copy Markdown
|
|
View reviewed changes
Comment thread 1-js/11-async/02-promise-basics/article.md
Outdated
| Assim como existe uma cláusula `finally` em um `try {...} catch {...}` comum, existe `finally` em promises também . | ||
|
|
||
| The call `.finally(f)` is similar to `.then(f, f)` in the sense that `f` runs always, when the promise is settled : be it resolve or reject. | ||
| A chamada `.finally(f)` é parecida com `.then(f, f)` , no sentido de que `f` sempre roda quando a promise é resolvida ( settled ): seja em ` resolve ` ou ` reject ` . |
Outdated
| Resumindo, o executor deve realizar um trabalho (geralmente algo que leva tempo) e então chamar `resolve` ou `reject` para mudar o estado da promise correspondente . | ||
|
|
||
| A promise that is either resolved or rejected is called "settled" , as opposed to an initially "pending" promise . | ||
| Uma promise que foi resolvida ou rejeitada é chamada de "settled" (encerrada/resolvida), em contraste com uma promise inicialmente "pending" (pendente) . |
Outdated
| // assim o indicador de carregamento sempre é parado antes de continuarmos | ||
| */!* | ||
| .then( result => show result, err => show error ) | ||
| .then( resultado => mostra o resultado, erro => mostra o erro ) |
Outdated
|  | ||
|
|
||
| That was an example of a successful job completion, a "fulfilled promise " . | ||
| Esse foi um exemplo de uma conclusão de trabalho bem-sucedida, uma " promise cumprida" (fulfilled) . |
Outdated
| A chamada `.finally(f)` é parecida com `.then(f, f)` , no sentido de que `f` sempre roda quando a promise é resolvida ( settled ): seja em ` resolve ` ou ` reject ` . | ||
|
|
||
| The idea of `finally` is to set up a handler for performing cleanup/finalizing after the previous operations are complete . | ||
| A ideia do `finally` é configurar um handler para fazer a limpeza/finalização depois que as operações anteriores forem concluídas . |
Outdated
| 3. A *promise* is a special JavaScript object that links the "producing code" and the "consuming code" together. In terms of our analogy: this is the "subscription list ". The "producing code" takes whatever time it needs to produce the promised result, and the "promise" makes that result available to all of the subscribed code when it's ready . | ||
| 1. Um "código produtor" que faz alguma coisa e leva um tempo pra isso. Por exemplo, algum código que carrega dados pela rede. Esse é o "cantor ". | ||
| 2. Um "código consumidor" que quer o resultado do "código produtor" assim que ele estiver pronto. Várias funções podem precisar desse resultado. Esses são os "fãs ". | ||
| 3. Uma *promise* é um objeto especial do JavaScript que liga o "código produtor" e o "código consumidor". Em termos da nossa analogia: essa é a "lista de inscrição ". O "código produtor" leva o tempo que precisar para produzir o resultado prometido, e a "promise" disponibiliza esse resultado para todo o código inscrito assim que ele estiver pronto . |
Outdated
| |----------|-----------| | ||
| | Promises allow us to do things in the natural order. First, we run `loadScript(script)`, and `.then` we write what to do with the result . | We must have a `callback` function at our disposal when calling `loadScript(script, callback)`. In other words, we must know what to do with the result *before* `loadScript` is called . | | ||
| | We can call `.then` on a Promise as many times as we want. Each time, we're adding a new "fan ", a new subscribing function, to the "subscription list ". More about this in the next chapter : [](info:promise-chaining). | There can be only one callback. | | ||
| | Promises nos permitem fazer as coisas na ordem natural . Primeiro, rodamos `loadScript(script)`, e `.then` escrevemos o que fazer com o resultado . | Precisamos ter uma função `callback` disponível ao chamar `loadScript(script, callback)`. Em outras palavras, precisamos saber o que fazer com o resultado *antes* de `loadScript` ser chamado . | |
Outdated
| // seu código | ||
| } | ||
|
|
||
| delay(3000).then(() => alert('runs after 3 seconds')); |
Apply review suggestions from gabifs
0a7d6b8
diogoosz commented Nov 7, 2026
Copy link Copy Markdown
Contributor
Author
|
Obrigado pela revisão, @gabifs ! Apliquei tudo:
|
c8abd97
into
javascript-tutorial : master
Nov 7, 2026
1 check passed
gabifs
mentioned this pull request
Nov 7, 2026
Portuguese Translation Progress
#1
Open
Sign up for free
to join this conversation on GitHub .
Already have an account?
Sign in to comment