Skip to content

Commit 05a868b

Browse files
committed
feat: use-request/useRequestProvider global option
1 parent 067a93f commit 05a868b

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

packages/hooks/src/useRequest/useRequestImplement.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,21 @@ import { ref, reactive, toRefs, onMounted, onUnmounted, unref, inject } from 'vu
33
import Fetch from './Fetch'
44
import { USEREQUEST_GLOBAL_OPTIONS_PROVIDE_KEY } from './config'
55
import { UseRequestOptions, UseRequestPlugin, useRequestResult, UseRequestService } from './types'
6-
import { merge } from 'lodash'
76

87
function useRequestImplement<TData, TParams extends any[]>(
98
service: UseRequestService<TData, TParams>,
109
options: UseRequestOptions<TData, TParams, any> = {},
1110
plugins: UseRequestPlugin<TData, TParams>[] = [],
1211
) {
1312
// global option
14-
const USEREQUEST_GLOBAL_OPTIONS = inject(USEREQUEST_GLOBAL_OPTIONS_PROVIDE_KEY)
13+
const USEREQUEST_GLOBAL_OPTIONS = inject<Record<string, any>>(
14+
USEREQUEST_GLOBAL_OPTIONS_PROVIDE_KEY,
15+
)
1516
// read option
16-
const { initialData = undefined, manual = false, ready = true, ...rest } = merge(
17-
USEREQUEST_GLOBAL_OPTIONS,
18-
options ?? {},
19-
) as Record<string, any>
17+
const { initialData = undefined, manual = false, ready = true, ...rest } = {
18+
...(USEREQUEST_GLOBAL_OPTIONS ?? {}),
19+
...(options ?? {}),
20+
} as Record<string, any>
2021

2122
const fetchOptions = {
2223
manual,

0 commit comments

Comments
 (0)