Skip to content

Commit

Permalink
feat: added back mutateAsync
Browse files Browse the repository at this point in the history
  • Loading branch information
mbret committed Dec 29, 2024
1 parent 51b8924 commit c7e1f98
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions src/lib/queries/useSwitchMutation$.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ export function useSwitchMutation$<
const [cancel$, cancel] = useObservableCallback()
type TDataOrNull = TData | null

const {
mutate,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
mutateAsync: _removed,
...rest
} = useMutation$<TDataOrNull, TError, TVariables, TContext>(
const { mutate, mutateAsync, ...rest } = useMutation$<
TDataOrNull,
TError,
TVariables,
TContext
>(
{
...options,
mutationFn: (variables) => {
Expand All @@ -44,5 +44,14 @@ export function useSwitchMutation$<
[mutate, cancel]
)

return { ...rest, mutate: mutateSwitch }
const mutateAsyncSwitch = useCallback(
(variables: TVariables) => {
cancel()

return mutateAsync(variables)
},
[mutateAsync, cancel]
)

return { ...rest, mutate: mutateSwitch, mutateAsync: mutateAsyncSwitch }
}

0 comments on commit c7e1f98

Please sign in to comment.