LoadMore API
LoadMore extensions.
const { ...ReturnValues } = useLoadMore<R, P, FR, LR>(Service, Options);
TS Generic description
Generics not listed are consistent with the definition in the Public API chapter
LR
is a generic of dataList
. (Note: This generic is subject to unknown[]
constraints)
See also: LoadMore
Note
The following API is a superset of Public API. If there are no special instructions, it is consistent with Public API.
Return Values
dataList
Type:
Ref<LR>
Default:
[]
All requests data (data taken from data[listkey]) merge array.
loadingMore
Type:
Ref<boolean>
Default:
false
Is loading more, used to record whether
loadMore()
is triggering. If you want to determine whetherService
is requesting, please useloading
.
New in 1.1.0
refreshingType:
Ref<boolean>
Default:
false
Is refreshing, used to record whether
refresh()
is triggering.
noMore
Type:
Ref<boolean>
Default:
false
Is there have more data, need use with
isNoMore
.
loadMore
Type:
() => void
Default:
0
Trigger load more.
reload
Type:
() => void
Trigger reload, used to clear all request status and request data (includes
dataList
), and trigger the request again.
New in 1.1.0
refreshType:
() => void
Re-request data. Unlike
reload()
, this method will not cleardataList
before the end of the request. It can be used to pull down to refresh.
Not Support
queriesIn LoadMore
mode, Concurrent Request is not supported
Not Support
mutateIn LoadMore
mode, Mutation is not supported
Service
Request Method
Type:
(returnData: ReturnDataType | undefined, ...params: P) => Promise<R>
| (returnData: ReturnDataType | undefined, ...params: P) => string
| (returnData: ReturnDataType | undefined, ...params: P) => ({ url: string; [key: string]: any; })
Details:
The type of the first parameter is explained as follows (when the first request is made, the first parameter is
undefined
)type ReturnDataType = { data: R; // The result of the last request dataList: LR; // The result of the current request merged array };
Not Support
StringNot supported in LoadMore
mode.
Not Support
ObjectNot supported in LoadMore
mode.
Options
listKey
- Type:
string
- Default:
list
- Details:
Gets the value at path
of data
. like lodash.get
, so you can reference lodash documentopen in new window.
const data = { a: [{ b: { c: 3 } }] };
const listKey = 'a[0].b.c';
// => 3
Specify the path of the data
attribute in listKey
.
isNoMore
Type:
(data: R) => boolean
Default:
false
Details:
Is there has more data.
Not Support
queryKeyIn LoadMore
mode, Concurrent Request is not supported