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

add helper function to clear deduping intervals #720

Closed
wants to merge 1 commit into from
Closed
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
8 changes: 7 additions & 1 deletion src/use-swr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,12 @@ const mutate: mutateInterface = async (
return data
}

const clearDedupingInterval = (_key: keyInterface) => {
const [key] = cache.serializeKey(_key)
delete CONCURRENT_PROMISES[key]
delete CONCURRENT_PROMISES_TS[key]
}

function useSWR<Data = any, Error = any>(
key: keyInterface
): responseInterface<Data, Error>
Expand Down Expand Up @@ -752,5 +758,5 @@ function useSWR<Data = any, Error = any>(

const SWRConfig = SWRConfigContext.Provider

export { trigger, mutate, SWRConfig }
export { trigger, mutate, clearDedupingInterval, SWRConfig }
export default useSWR