Skip to content
On this page

UseRequest Fetching Plugin

A plugin for global request state management based on pinia implementation. The useRequest Fetching plugin will internally create a state management instance of pinia to collect request information.

Feature

  • Act as the intermediate state for all requests, where users can operate on the collected request results.
  • Whether all requests have been completed and automatically collected to determine whether all requests have been completed.
  • Non intrusive, all configurations are injected by plugins, and are non-invasive to the current function.

Install


# It is necessary to ensure that the application contains pinia and has been used by Vue instances.

1. npm i pinia

2. npm i @vue-hooks-plus/use-request-plugins


# It is necessary to ensure that the application contains pinia and has been used by Vue instances.

1. npm i pinia

2. npm i @vue-hooks-plus/use-request-plugins

Demo

API

import { useRequest } from 'vue-hooks-plus'
import { useFetchingPlugin } from '@vue-hooks-plus/use-request-plugins'

useRequest(
  service,
  {
    fetchingKey: (params: any[]) => string
    onFetching: (current:any,record:Record<string,any>) => void,
    isFetching: (_isFetching: boolean) => void,
  },
  [useFetchingPlugin],
)
import { useRequest } from 'vue-hooks-plus'
import { useFetchingPlugin } from '@vue-hooks-plus/use-request-plugins'

useRequest(
  service,
  {
    fetchingKey: (params: any[]) => string
    onFetching: (current:any,record:Record<string,any>) => void,
    isFetching: (_isFetching: boolean) => void,
  },
  [useFetchingPlugin],
)

Options

PropertyDescriptionType
fetchingKeyThe identification key of the status needs to be collected, and if it exists, it will be collected by the status
(params: any[]) => string
onFetchingIntermediate state function callback, the first parameter current is the current state of itself, and the second parameter record is all states(current:any,record:Record<string,any>) => void
isFetchingOfficial built-in function to determine whether all request statuses have been completed(_isFetching: boolean) => void

Source

SourceDocsDemo