Skip to content

Commit

Permalink
Merge pull request #42 from marekdedic/patch-1
Browse files Browse the repository at this point in the history
Fixed mutate not accepting a function
  • Loading branch information
ConsoleTVs committed Mar 5, 2023
2 parents b37f2cc + 97437ab commit 27fbaad
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/sswr.ts
@@ -1,4 +1,4 @@
import { SWR, SWRKey, SWROptions, SWRMutateOptions, SWRRevalidateOptions, CacheClearOptions } from 'swrev'
import { SWR, SWRKey, SWROptions, SWRMutateOptions, SWRMutateValue, SWRRevalidateOptions, CacheClearOptions } from 'swrev'
import { onDestroy, onMount } from 'svelte'
import { writable, derived } from 'svelte/store'

Expand Down Expand Up @@ -40,7 +40,7 @@ export class SSWR extends SWR {
onDestroy(() => unsubscribe?.())

// Mutates the current key.
const mutate = (value: D, ops?: Partial<SWRMutateOptions<D>>) => {
const mutate = (value: SWRMutateValue<D>, ops?: Partial<SWRMutateOptions<D>>) => {
return this.mutate(this.resolveKey(key), value, {
revalidateOptions: options,
...ops,
Expand Down Expand Up @@ -160,7 +160,7 @@ export const useSWR = <D = any, E = Error>(
* This is used to replace the cache contents of the
* given key manually.
*/
export const mutate = <D = any>(key: SWRKey, value: D, options?: Partial<SWRMutateOptions<D>>) => {
export const mutate = <D = any>(key: SWRKey, value: SWRMutateValue<D>, options?: Partial<SWRMutateOptions<D>>) => {
return swr.mutate<D>(key, value, options)
}

Expand Down

0 comments on commit 27fbaad

Please sign in to comment.