Skip to content

Commit

Permalink
Merge branch 'master' into enhance-lint
Browse files Browse the repository at this point in the history
  • Loading branch information
huozhi committed May 20, 2021
2 parents 99cb5f1 + 0596287 commit 66792ff
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
19 changes: 14 additions & 5 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,20 @@ export type Mutator<Data = any> = (
shouldRevalidate?: boolean
) => Promise<Data | undefined>

export type ScopedMutator<Data> = (
key: Key,
data?: Data | Promise<Data> | MutatorCallback<Data>,
shouldRevalidate?: boolean
) => Promise<Data | undefined>
export interface ScopedMutator<Data = any> {
/** This is used for bound mutator */
(
key: Key,
data?: Data | Promise<Data> | MutatorCallback<Data>,
shouldRevalidate?: boolean
): Promise<Data | undefined>
/** This is used for global mutator */
<T = any>(
key: Key,
data?: T | Promise<T> | MutatorCallback<T>,
shouldRevalidate?: boolean
): Promise<T | undefined>
}

export type KeyedMutator<Data> = (
data?: Data | Promise<Data> | MutatorCallback<Data>,
Expand Down
4 changes: 2 additions & 2 deletions src/use-swr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,8 @@ Object.defineProperty(SWRConfig, 'default', {
export const mutate = internalMutate.bind(
null,
defaultConfig.cache
) as ScopedMutator<any>
) as ScopedMutator

export function createCache<Data>(
provider: Cache
): {
Expand All @@ -713,5 +714,4 @@ export function createCache<Data>(
mutate: internalMutate.bind(null, cache) as ScopedMutator<Data>
}
}

export default useSWR
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3529,9 +3529,9 @@ has@^1.0.3:
function-bind "^1.1.1"

hosted-git-info@^2.1.4:
version "2.8.5"
resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.8.5.tgz#759cfcf2c4d156ade59b0b2dfabddc42a6b9c70c"
integrity sha512-kssjab8CvdXfcXMXVcvsXum4Hwdq9XGtRD3TteMEvEbq0LXyiNQr6AprqKqfeaDXze7SxWvRxdpwE6ku7ikLkg==
version "2.8.9"
resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.8.9.tgz#dffc0bf9a21c02209090f2aa69429e1414daf3f9"
integrity sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw==

html-encoding-sniffer@^1.0.2:
version "1.0.2"
Expand Down

0 comments on commit 66792ff

Please sign in to comment.