Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(*): unify & use noop #8294

Merged
merged 5 commits into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/angular-query-experimental/src/util/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ export function shouldThrowError<T extends (...args: Array<any>) => boolean>(
return !!throwError
}

export function noop() {}
export function noop(): void {}
2 changes: 1 addition & 1 deletion packages/query-async-storage-persister/src/utils.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export function noop() {}
export function noop(): void {}
2 changes: 1 addition & 1 deletion packages/query-sync-storage-persister/src/utils.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export function noop() {}
export function noop(): void {}

Check warning on line 1 in packages/query-sync-storage-persister/src/utils.ts

View check run for this annotation

Codecov / codecov/patch

packages/query-sync-storage-persister/src/utils.ts#L1

Added line #L1 was not covered by tests
2 changes: 1 addition & 1 deletion packages/react-query/src/useBaseQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
React.useCallback(
(onStoreChange) => {
const unsubscribe = isRestoring
? () => undefined
? noop

Check warning on line 91 in packages/react-query/src/useBaseQuery.ts

View check run for this annotation

Codecov / codecov/patch

packages/react-query/src/useBaseQuery.ts#L91

Added line #L91 was not covered by tests
: observer.subscribe(notifyManager.batchCalls(onStoreChange))

// Update result to make sure we did not miss any query updates
Expand Down
3 changes: 2 additions & 1 deletion packages/react-query/src/useQueries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
shouldSuspend,
willFetch,
} from './suspense'
import { noop } from './utils'
import type {
DefinedUseQueryResult,
UseQueryOptions,
Expand Down Expand Up @@ -280,7 +281,7 @@
React.useCallback(
(onStoreChange) =>
isRestoring
? () => undefined
? noop

Check warning on line 284 in packages/react-query/src/useQueries.ts

View check run for this annotation

Codecov / codecov/patch

packages/react-query/src/useQueries.ts#L284

Added line #L284 was not covered by tests
: observer.subscribe(notifyManager.batchCalls(onStoreChange)),
[observer, isRestoring],
),
Expand Down
2 changes: 1 addition & 1 deletion packages/react-query/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ export function shouldThrowError<T extends (...args: Array<any>) => boolean>(
return !!throwError
}

export function noop() {}
export function noop(): void {}
5 changes: 3 additions & 2 deletions packages/solid-query/src/createQueries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
} from 'solid-js'
import { useQueryClient } from './QueryClientProvider'
import { useIsRestoring } from './isRestoring'
import { noop } from './utils'
import type { CreateQueryResult, SolidQueryOptions } from './types'
import type { Accessor } from 'solid-js'
import type { QueryClient } from './QueryClient'
Expand Down Expand Up @@ -305,10 +306,10 @@ export function createQueries<
})
})

let unsubscribe: () => void = () => undefined
let unsubscribe = noop
createComputed<() => void>((cleanup) => {
cleanup?.()
unsubscribe = isRestoring() ? () => undefined : subscribeToObserver()
unsubscribe = isRestoring() ? noop : subscribeToObserver()
// cleanup needs to be scheduled after synchronous effects take place
return () => queueMicrotask(unsubscribe)
})
Expand Down
2 changes: 1 addition & 1 deletion packages/solid-query/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ export function shouldThrowError<T extends (...args: Array<any>) => boolean>(
return !!throwError
}

export function noop() {}
export function noop(): void {}
2 changes: 1 addition & 1 deletion packages/svelte-query/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ export function isSvelteStore<T extends object>(
return 'subscribe' in obj && typeof obj.subscribe === 'function'
}

export function noop() {}
export function noop(): void {}
Loading