-
Notifications
You must be signed in to change notification settings - Fork 3
非同期処理の追加 (新セクション作成後移動) #507
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Deploying with
|
Latest commit: |
be3167e
|
Status: | ✅ Deploy successful! |
Preview URL: | https://918e5a19.utcode-learn.pages.dev |
Branch Preview URL: | https://write-promise.utcode-learn.pages.dev |
クロージャの話も入れた方がいいですかね?重要ですが、知らなくても理解できそうなので省きましたが |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
お疲れ様です!!
最初のほうは力を使ってる感があるのですが最後のほう適当になってません??
主に第一引数を `resolve`、第二引数を `reject` と命名した無名関数が渡されます。 | ||
`Promise` が成功した時には `resolve`、失敗した時には `reject` にそれぞれ結果を渡して関数実行されます。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- 関数のインターフェースの説明で「主に」は曖昧過ぎます。
- resolve と reject が関数であることが説明できていません。
- 「結果を渡して関数実行」はどういう意味でしょうか?
`then` メソッドは、引数にコールバック関数を 1 つとり、`Promise` オブジェクトの `PromiseState` が `fulfilled` になった後 (つまり `resolve` 関数が実行された後)にコールバック関数を実行します。 | ||
コールバック関数の引数には `PromiseResult` が渡されます。 | ||
|
||
`then` メソッドは、`PromiseState` が `fulfilled`、`PromiseResult` がコールバック関数の返り値である新しい `Promise` オブジェクトを生成して返します。そのため、メソッドチェーンのような書き方をすることができます。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
「メソッドチェーン」は初出
いま思いついたんですけど、Promiseオブジェクトだけ先に持ってきてメソッド群をasync/awaitの後に持ってくるのが1番分かりやすそうなので、明日移動します。 |
No description provided.