Skip to content

Commit

Permalink
feat(199): add ability to disable cache
Browse files Browse the repository at this point in the history
fixes #199
  • Loading branch information
simoneb committed Apr 11, 2020
1 parent 32e4303 commit 602e0ee
Show file tree
Hide file tree
Showing 6 changed files with 555 additions and 526 deletions.
4 changes: 3 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"semi": false,
"singleQuote": true
"singleQuote": true,
"trailingComma": "none",
"arrowParens": "avoid"
}
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,7 @@
},
"lint-staged": {
"src/**/*.{js,md}": [
"prettier --write",
"git add"
"eslint --fix"
]
},
"config": {
Expand Down
2 changes: 1 addition & 1 deletion src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export interface RefetchOptions {

export interface ConfigureOptions {
axios?: AxiosInstance | AxiosStatic | any
cache?: LRUCache<any, any>
cache?: LRUCache<any, any> | false
}

export interface UseAxios {
Expand Down
9 changes: 4 additions & 5 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,17 @@ export function makeUseAxios(configurationOptions) {
axiosInstance = StaticAxios
}

resetConfigure()

function configure(options = {}) {
if (options.axios) {
if (options.axios !== undefined) {
axiosInstance = options.axios
}

if (options.cache) {
if (options.cache !== undefined) {
cache = options.cache
}
}

resetConfigure()
configure(configurationOptions)

function loadCache(data) {
Expand Down Expand Up @@ -140,7 +139,7 @@ export function makeUseAxios(configurationOptions) {
}

function executeRequest(config, options, dispatch) {
if (options.useCache) {
if (cache && options.useCache) {
return executeRequestWithCache(config, dispatch)
}

Expand Down
Loading

0 comments on commit 602e0ee

Please sign in to comment.