Skip to content

Commit

Permalink
refactor(*): Import noop function from utils (#6964)
Browse files Browse the repository at this point in the history
* refactor(*): Import noop function from utils

* Revert "refactor(*): Import noop function from utils"

This reverts commit c76f36f.

* refactor(*): Add noop function in each package

---------

Co-authored-by: Dominik Dorfmeister <[email protected]>
  • Loading branch information
saul-atomrigs and TkDodo authored Feb 28, 2024
1 parent 18c2cae commit b7b5096
Show file tree
Hide file tree
Showing 13 changed files with 17 additions and 19 deletions.
3 changes: 1 addition & 2 deletions packages/angular-query-experimental/src/inject-mutation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { MutationObserver, notifyManager } from '@tanstack/query-core'
import { assertInjector } from './util/assert-injector/assert-injector'
import { signalProxy } from './signal-proxy'
import { injectQueryClient } from './inject-query-client'
import { noop } from './util'
import type { DefaultError, QueryClient } from '@tanstack/query-core'
import type { Injector } from '@angular/core'

Expand Down Expand Up @@ -64,5 +65,3 @@ export function injectMutation<
>
})
}

function noop() {}
1 change: 1 addition & 0 deletions packages/angular-query-experimental/src/util/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export function noop() {}
6 changes: 2 additions & 4 deletions packages/query-async-storage-persister/src/asyncThrottle.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import { noop } from './utils'

export interface AsyncThrottleOptions {
interval?: number
onError?: (error: unknown) => void
}

const noop = () => {
/* do nothing */
}

export function asyncThrottle<TArgs extends ReadonlyArray<unknown>>(
func: (...args: TArgs) => Promise<void>,
{ interval = 1000, onError = noop }: AsyncThrottleOptions = {},
Expand Down
3 changes: 1 addition & 2 deletions packages/query-async-storage-persister/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { asyncThrottle } from './asyncThrottle'
import { noop } from './utils'
import type {
AsyncStorage,
MaybePromise,
Expand Down Expand Up @@ -99,5 +100,3 @@ export const createAsyncStoragePersister = ({
removeClient: noop,
}
}

function noop() {}
1 change: 1 addition & 0 deletions packages/query-async-storage-persister/src/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export function noop() {}
3 changes: 1 addition & 2 deletions packages/query-sync-storage-persister/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { noop } from './utils'
import type {
PersistRetryer,
PersistedClient,
Expand Down Expand Up @@ -108,5 +109,3 @@ function throttle<TArgs extends Array<any>>(
}
}
}

function noop() {}
1 change: 1 addition & 0 deletions packages/query-sync-storage-persister/src/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export function noop() {}
4 changes: 1 addition & 3 deletions packages/react-query/src/useMutation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import * as React from 'react'
import { MutationObserver, notifyManager } from '@tanstack/query-core'
import { useQueryClient } from './QueryClientProvider'
import { shouldThrowError } from './utils'
import { noop, shouldThrowError } from './utils'
import type {
UseMutateFunction,
UseMutationOptions,
Expand Down Expand Up @@ -63,5 +63,3 @@ export function useMutation<

return { ...result, mutate, mutateAsync: result.mutate }
}

function noop() {}
2 changes: 2 additions & 0 deletions packages/react-query/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ export function shouldThrowError<T extends (...args: Array<any>) => boolean>(

return !!throwError
}

export function noop() {}
4 changes: 1 addition & 3 deletions packages/solid-query/src/createMutation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { MutationObserver } from '@tanstack/query-core'
import { createComputed, createMemo, on, onCleanup } from 'solid-js'
import { createStore } from 'solid-js/store'
import { useQueryClient } from './QueryClientProvider'
import { shouldThrowError } from './utils'
import { noop, shouldThrowError } from './utils'
import type { DefaultError } from '@tanstack/query-core'
import type { QueryClient } from './QueryClient'
import type {
Expand Down Expand Up @@ -74,5 +74,3 @@ export function createMutation<

return state
}

function noop() {}
2 changes: 2 additions & 0 deletions packages/solid-query/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ export function shouldThrowError<T extends (...args: Array<any>) => boolean>(

return !!throwError
}

export function noop() {}
4 changes: 1 addition & 3 deletions packages/svelte-query/src/createMutation.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { derived, get, readable } from 'svelte/store'
import { MutationObserver, notifyManager } from '@tanstack/query-core'
import { useQueryClient } from './useQueryClient'
import { isSvelteStore } from './utils'
import { isSvelteStore, noop } from './utils'
import type {
CreateMutateFunction,
CreateMutationOptions,
Expand Down Expand Up @@ -47,5 +47,3 @@ export function createMutation<

return { subscribe }
}

function noop() {}
2 changes: 2 additions & 0 deletions packages/svelte-query/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ export function isSvelteStore<T extends object>(
): obj is Readable<T> {
return 'subscribe' in obj && typeof obj.subscribe === 'function'
}

export function noop() {}

0 comments on commit b7b5096

Please sign in to comment.