-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
398 changed files
with
8,276 additions
and
10,868 deletions.
There are no files selected for viewing
Submodule illa-design
updated
from b52aca to add0c6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { AxiosRequestConfig } from "axios" | ||
import qs from "qs" | ||
|
||
let pendingPollMap = new Map<string, (reason?: any) => void>() | ||
|
||
export const generateUniqueKey = (config: AxiosRequestConfig) => | ||
[ | ||
config.method, | ||
config.url, | ||
qs.stringify(config.params), | ||
qs.stringify(config.data), | ||
].join("/") | ||
|
||
export const clearRequestPendingPool = () => { | ||
pendingPollMap.forEach((cancel) => { | ||
cancel?.() | ||
}) | ||
pendingPollMap.clear() | ||
} | ||
|
||
export const removeRequestPendingPool = (config: AxiosRequestConfig) => { | ||
const key = generateUniqueKey(config) | ||
if (pendingPollMap.has(key)) { | ||
const cancel = pendingPollMap.get(key) | ||
cancel?.() | ||
pendingPollMap.delete(key) | ||
} | ||
} | ||
|
||
export const addRequestPendingPool = (config: AxiosRequestConfig) => { | ||
removeRequestPendingPool(config) | ||
const key = generateUniqueKey(config) | ||
const controller = new AbortController() | ||
config.signal = controller.signal | ||
if (!pendingPollMap.has(key)) { | ||
pendingPollMap.set(key, controller.abort.bind(controller)) | ||
} | ||
} |
Oops, something went wrong.