Skip to content

Commit 4b77b30

Browse files
committed
docs: add docs example for the afcl table with abort controller
1 parent 43a687d commit 4b77b30

File tree

1 file changed

+37
-0
lines changed
  • adminforth/documentation/docs/tutorial/03-Customization

1 file changed

+37
-0
lines changed

adminforth/documentation/docs/tutorial/03-Customization/15-afcl.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1237,6 +1237,43 @@ If you want to make table header or pagination, you can add `makeHeaderSticky`,
12371237
></Table>
12381238
```
12391239

1240+
### Don't block pagination on loading
1241+
1242+
Sometimes you might want to allow user switch between pages, even if old request wasn't finished. For these porpuses you can use `blockPaginationOnLoading` and `abortSignal` in data callback:
1243+
```ts
1244+
<Table
1245+
:columns="[
1246+
{ label: 'Name', fieldName: 'name' },
1247+
{ label: 'Age', fieldName: 'age' },
1248+
{ label: 'Country', fieldName: 'country' },
1249+
]"
1250+
:data="loadPageData"
1251+
//diff-add
1252+
:blockPaginationOnLoading="false"
1253+
:pageSize="3">
1254+
</Table>
1255+
1256+
1257+
...
1258+
1259+
async function loadPageData(data, abortSignal) {
1260+
const { offset, limit } = data;
1261+
// in real app do await callAdminForthApi or await fetch to get date, use offset and limit value to slice data
1262+
await new Promise(resolve => setTimeout(resolve, offset === 500)) // simulate network delay
1263+
if (abortSignal.abort) return; // since result won't be displayed, we stop computing
1264+
1265+
return {
1266+
data: [
1267+
{ name: 'John', age: offset, country: 'US' },
1268+
{ name: 'Rick', age: offset+1, country: 'CA' },
1269+
{ name: 'Alice', age: offset+2, country: 'BR' },
1270+
],
1271+
total: 30 // should return total amount of records in database
1272+
}
1273+
}
1274+
1275+
```
1276+
12401277
## ProgressBar
12411278

12421279
<div class="split-screen" >

0 commit comments

Comments
 (0)