LoadMore API

LoadMore extensions.

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 a list array, the type is { list: any[], ...other }
    • The input parameter of Service is the latest merged data

Return Values

data

  • Type: shallowRef<DataType>

  • Default: []

    The data returned by Service must contain a list array, the type is { list: any[], ...other }, the list attribute is the aggregated data

dataList

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

  • Default: []

    list array in data.

error

  • Type: shallowRef<Error>

  • Default: []

    If an error is thrown internally, it will be received by error and returned.

loading

  • Type: Ref<boolean>

  • Default: false

    Service The execution status of the request

loadingMore

  • Type: Ref<boolean>

  • Default: false

    Is more data request in progress

noMore

  • Type: Ref<boolean>

  • Default: false

    Is there have more data, need use with isNoMore.

loadMore

  • Type: () => void

  • Default: 0

    Load more data, it will automatically catch the exception, and handle it through onError

loadMoreAsync

  • Type: () => Promise<DataType>

    Load more data, which is consistent with the behavior of loadMore, but returns Promise, so you need to handle the exception yourself

refresh

  • Type: () => void

    Load the first page of data, it will automatically catch the exception, and handle it through onError

refreshAsync

  • Type: () => void

    Load the first page of data, which is consistent with the behavior of refresh, but returns Promise, so you need to handle the exception yourself

mutate

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

    Modify data directly

cancel

  • Type: () => void

    Cancel the request currently in progress

Options

isNoMore

  • Type: (data: R) => boolean

  • Default: false

  • Details:

    Determines if there is no more data, the input parameter is the latest merged data

manual

  • Type: boolean

  • Default: false

  • Details:

    If set to true, you need to manually call loadMore or loadMoreAsync to trigger execution

ready reactivity

  • Type: Ref<boolean>

  • Default: false

  • Details:

    Same as ready of useRequest

refreshDeps

  • Type: WatchSource<any>[]

  • Default: []

  • Details:

    Same as refreshDeps of useRequest

refreshDepsAction

debounceInterval reactivity

  • Type: number | Ref<number>

  • Default: undefined

  • Details:

    Same as debounceInterval of useRequest

debounceOptions reactivity

  • Type: DebounceOptions | Reactive<DebounceOptions>

  • Details:

    Same as debounceOptions of useRequest

throttleInterval reactivity

  • Type: number | Ref<number>

  • Default: undefined

  • Details:

    Same as throttleInterval of useRequest

throttleOptions reactivity

  • Type: ThrottleOptions | Reactive<ThrottleOptions>

  • Details:

    Same as throttleOptions of useRequest

errorRetryCount reactivity

  • Type: number | Ref<number>

  • Default: 0

  • Details:

    Same as errorRetryCount of useRequest

errorRetryInterval reactivity

onBefore

  • Type: () => void

  • Details:

    Triggered before Service execution

onAfter

  • Type: () => void

  • Details:

    Triggered when Service execution is complete

onSuccess

  • Type: (data: DataType) => void

  • Details:

    Triggered when Service resolve

onError

  • Type: (error: Error) => void

  • Details:

    Triggered when Service reject

Last Updated: 7/1/2022, 8:28:34 AM
Contributors: John