Skip to content

Commit

Permalink
chore(utils): Ensure consistent declaration style of utility function…
Browse files Browse the repository at this point in the history
…s and standardize parameters for the sleep method (#7554)

* refactor: Changed parameter names to match those in other sleep utility functions.

* refactor: Most utility functions are defined as regular functions, updated this one to match.

* fix: formatting
  • Loading branch information
Lennon57 authored Jul 17, 2024
1 parent eb21d1e commit 95d814a
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions packages/query-core/src/__tests__/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ export function sleep(timeout: number): Promise<void> {
})
}

export const executeMutation = <TVariables>(
export function executeMutation<TVariables>(
queryClient: QueryClient,
options: MutationOptions<any, any, TVariables, any>,
variables: TVariables,
) => {
) {
return queryClient
.getMutationCache()
.build(queryClient, options)
Expand Down
8 changes: 4 additions & 4 deletions packages/query-core/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -340,9 +340,9 @@ function hasObjectPrototype(o: any): boolean {
return Object.prototype.toString.call(o) === '[object Object]'
}

export function sleep(ms: number): Promise<void> {
export function sleep(timeout: number): Promise<void> {
return new Promise((resolve) => {
setTimeout(resolve, ms)
setTimeout(resolve, timeout)
})
}

Expand Down Expand Up @@ -378,7 +378,7 @@ export function addToStart<T>(items: Array<T>, item: T, max = 0): Array<T> {
export const skipToken = Symbol()
export type SkipToken = typeof skipToken

export const ensureQueryFn = <
export function ensureQueryFn<
TQueryFnData = unknown,
TQueryKey extends QueryKey = QueryKey,
>(
Expand All @@ -387,7 +387,7 @@ export const ensureQueryFn = <
queryHash?: string
},
fetchOptions?: FetchOptions<TQueryFnData>,
): QueryFunction<TQueryFnData, TQueryKey> => {
): QueryFunction<TQueryFnData, TQueryKey> {
if (process.env.NODE_ENV !== 'production') {
if (options.queryFn === skipToken) {
console.error(
Expand Down
4 changes: 2 additions & 2 deletions packages/query-persist-client-core/src/__tests__/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export function sleep(timeout: number): Promise<void> {
})
}

export const createMockPersister = (): Persister => {
export function createMockPersister(): Persister {
let storedState: PersistedClient | undefined

return {
Expand All @@ -30,7 +30,7 @@ export const createMockPersister = (): Persister => {
}
}

export const createSpyPersister = (): Persister => {
export function createSpyPersister(): Persister {
return {
persistClient: vi.fn(),
restoreClient: vi.fn(),
Expand Down
4 changes: 2 additions & 2 deletions packages/react-query/src/__tests__/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ export function renderWithClient(
} as any
}

export const Blink = ({
export function Blink({
duration,
children,
}: {
duration: number
children: React.ReactNode
}) => {
}) {
const [shouldShow, setShouldShow] = React.useState<boolean>(true)

React.useEffect(() => {
Expand Down
4 changes: 2 additions & 2 deletions packages/solid-query/src/__tests__/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ export function queryKey() {
return [`query_${queryKeyCount}`]
}

export const Blink = (
export function Blink(
props: {
duration: number
} & ParentProps,
) => {
) {
const [shouldShow, setShouldShow] = createSignal<boolean>(true)

createEffect(() => {
Expand Down

0 comments on commit 95d814a

Please sign in to comment.