LoadMore API

LoadMore extension.

const { ...ReturnValues } = useLoadMore<R>(Service, Options);

TS Type description

type DataType = { list: any[]; [key: string]: any };

See also: LoadMore

Service

Request methods

  • Type: (data?: DataType) => Promise<DataType>

  • Details:

    • The data returned by Service must contain an array named list, with the type of { list: any[], ...other }.
    • The input parameters of Service are the latest integrated data.

Return Values

data

  • Type: shallowRef<DataType>

  • Default: []

    The data returned by Service must contain an array named list, with the type of { list: any[], ...other }. The list property contains the aggregated data.

dataList

  • Type: Ref<DataType['list']>

  • Default: []

    The list array in data.

error

  • Type: shallowRef<Error>

  • Default: []

    Errors returned by Service.

loading

  • Type: Ref<boolean>

  • Default: false

    Whether the request is in progress.

loadingMore

  • Type: Ref<boolean>

  • Default: false

    Whether it is currently loading more data.

noMore

  • Type: Ref<boolean>

  • Default: false

    Whether it is currently loading more data. It needs to be used with isNoMore.

loadMore

  • Type: () => void

  • Default: 0

    Load more data. It will automatically catch exceptions and handle them through options.onError.

loadMoreAsync

  • Type: () => Promise<DataType>

    It is used in the same way as loadMore, but it returns a Promise and you need to handle exceptions yourself.

refresh

  • Type: () => void

    Reloads the first page of data. It will automatically catch exceptions and handle them through options.onError.

refreshAsync

  • Type: () => void

    It is used in the same way as refresh, but it returns a Promise and you need to handle exceptions yourself.

mutate

  • Type: (arg: (oldData: DataType) => DataType) => void | (newData: DataType) => void

    The result of directly modifying data.

cancel

  • Type: () => void

    Cancel request.

Options

isNoMore

  • Type: (data: R) => boolean

  • Default: false

  • Details:

    Check if there is more data available.

manual

  • Type: boolean

  • Default: false

  • Details:

    When set to true, you need to manually trigger loadMore or loadMoreAsync to initiate the request.

ready reactivity

  • Type: Ref<boolean>

  • Default: false

  • Details:

    Same as ready in useRequest

refreshDeps

  • Type: WatchSource<any>[]

  • Default: []

  • Details:

    Same as refreshDeps in useRequest

refreshDepsAction

debounceInterval reactivity

  • Type: number | Ref<number>

  • Default: undefined

  • Details:

    Same as debounceInterval in useRequest

debounceOptions reactivity

  • Type: DebounceOptions | Reactive<DebounceOptions>

  • Details:

    Same as debounceOptions in useRequest

throttleInterval reactivity

  • Type: number | Ref<number>

  • Default: undefined

  • Details:

    Same as throttleInterval in useRequest

throttleOptions reactivity

  • Type: ThrottleOptions | Reactive<ThrottleOptions>

  • Details:

    Same as throttleOptions in useRequest

errorRetryCount reactivity

  • Type: number | Ref<number>

  • Default: 0

  • Details:

    Same as errorRetryCount in useRequest

errorRetryInterval reactivity

onBefore

  • Type: () => void

  • Details:

    Triggered before the execution of Service.

onAfter

  • Type: () => void

  • Details:

    Triggered when Service execution is completed.

onSuccess

  • Type: (data: DataType) => void

  • Details:

    Triggered when Service resolves, with the data parameter.

onError

  • Type: (error: Error) => void

  • Details:

    Triggered when Service rejects, with the error parameter.

Last Updated: 7/6/2023, 3:23:08 AM
Contributors: John