Skip to content

20210521/await ブロッククイズ #1

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

Closed
myLifeAsaDog opened this issue May 19, 2021 · 3 comments
Closed

20210521/await ブロッククイズ #1

myLifeAsaDog opened this issue May 19, 2021 · 3 comments

Comments

@myLifeAsaDog
Copy link
Member

myLifeAsaDog commented May 19, 2021

テーマ

await ブロック

問題文

Svelte の特徴でもある await ブロックの書き方で、以下の内で間違っているものを一つ選んでください。

A

{#await promise}
  <p>...wait</p>
{:then number}
    <p>The number is {number}</p>
{:catch error}
    <p>{error.message}</p>
{/await}

B

{#await promise}
  <p>...wait</p>
{:catch}
    <p>error happened</p>
{/await}

C

{#await promise then number}
    <p>The number is {number}</p>
{/await}

D

{#await promise catch}
    <p>error happened</p>
{/await}

回答と解説

正解は D です!

この場合は下記のように引数を指定しなければなりません。

{#await promise catch error}
    <p>error happened</p>
{/await}

await ブロックについてはこちら
https://sveltejp.dev/docs#await

@myLifeAsaDog myLifeAsaDog changed the title await テンプレート構文クイズ 20210521/await テンプレート構文クイズ May 19, 2021
@knj4484
Copy link
Collaborator

knj4484 commented May 19, 2021

await テンプレート構文

ドキュメントで使われている用語に揃えて、awaitブロックにしませんか?

@myLifeAsaDog
Copy link
Member Author

これ正式名称が良く分かってなかったんですけど、特にこだわりはないので「ブロック」に合わせます

@myLifeAsaDog myLifeAsaDog changed the title 20210521/await テンプレート構文クイズ 20210521/await ブロッククイズ May 20, 2021
@knj4484
Copy link
Collaborator

knj4484 commented May 20, 2021

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants