javascript-tutorial / javascript-tutorial/en.javascript.info
Promise basics loading indicator example
オープン
まだ誰も着手していません。
- 主要言語
- HTML
- スター
- 25.5k
- フォーク
- 4k
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
So I was wrapping my head around why would the loading indicator stay active if the promise was settled? The solution did not clarify everything for me, the best explanation I found is:
new Promise((resolve, reject) => {
/* do something that takes time, and then call resolve or maybe reject */
const loading = document.createElement('img');
loading.src="https://media3.giphy.com/media/3oEjI6SIIHBdRxXI40/giphy.gif?cid=ecf05e471sfq2igav6mmdj3cvn1mr4j6br7k3tmo4jvg5t5u&rid=giphy.gif&ct=g";
document.body.append(loading);
})
*!*
// runs when the promise is settled, doesn't matter successfully or not
doSomething().finally(() => loading.remove());
// so the loading indicator is always stopped before we go on
*/!*
.then(result => show result, err => show error)
Could something like this improve the example?
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、issue で取り上げられている Promise basics のローディングインジケーターの例を見つけ、settled promises についてどのように説明しているかを確認してください。例を finally ベースで提案されているクリーンアップと比較し、その動作がより明確になる場合はチュートリアルを更新して、説明が成功した Promises と reject された Promises の両方をカバーしていることを確認してください。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- javascript
- 領域
- documentation
- issue の種類
- ドキュメント
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 45/100