Skip to content

Commit

Permalink
extend suspense doc
Browse files Browse the repository at this point in the history
  • Loading branch information
ECorreia45 committed Dec 17, 2023
1 parent ac516db commit 2692771
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Test

on:
push:
branches: ['main']
branches: ['main', 'next']
pull_request:
branches: ['main']
branches: ['main', 'next']

jobs:
build:
Expand Down
17 changes: 17 additions & 0 deletions docs-src/documentation/suspense-util.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,22 @@ export default ({
'html`${suspense(loadTodos)}`',
'typescript'
)}
<p>
To handle error, you can provide a third argument to handle how
to render the error message.
</p>
${CodeSnippet(
'const loadTodos = () => {\n' +
" return fetch('/api/todos')\n" +
' .then(res => res.json())\n' +
' .then(res => html`${repeat(res, renderTodo)}`)\n' +
'}\n\n\n' +
'html`${suspense(\n' +
' loadTodos,\n' +
' html`<p>Loading todos...</p>`,\n' +
' (error) => html`<error-display message="${error.message}" />`\n' +
')}`',
'typescript'
)}
`,
})

0 comments on commit 2692771

Please sign in to comment.