create-api-hooks
Advanced tools
Comparing version 0.0.41 to 0.0.42
@@ -10,2 +10,12 @@ import { useEffect, useState, useCallback, useRef } from 'react'; | ||
}; | ||
// @ts-ignore | ||
localStorage = localStorage || wx.getStorageSync || { | ||
getItem: function () { }, | ||
setItem: function () { } | ||
}; | ||
// @ts-ignore | ||
sessionStorage = sessionStorage || wx.getStorageSync || { | ||
getItem: function () { }, | ||
setItem: function () { } | ||
}; | ||
function createApiHooks(request) { | ||
@@ -17,5 +27,5 @@ var getRequestString = function (params) { | ||
var _b = _a === void 0 ? {} : _a, _c = _b.cache, cache = _c === void 0 ? true : _c, _d = _b.initValue, initValue = _d === void 0 ? {} : _d, params = _b.params, _e = _b.needInit, needInit = _e === void 0 ? true : _e, _f = _b.deepCache, deepCache = _f === void 0 ? false : _f, debounceInterval = _b.debounceInterval; | ||
initValue = cache === 'local' ? localStorage.getItem(getRequestString(params)) : cache === 'session' ? sessionStorage.getItem(getRequestString(params)) : cache | ||
? createApiHooksConfig.getCacheFn(getRequestString(params)) || initValue | ||
: initValue; | ||
initValue = (cache === 'local' ? localStorage.getItem(getRequestString(params)) : cache === 'session' ? sessionStorage.getItem(getRequestString(params)) : cache | ||
&& createApiHooksConfig.getCacheFn(getRequestString(params))) | ||
|| initValue; | ||
var initValueRef = useRef(initValue); | ||
@@ -22,0 +32,0 @@ var _g = useState(), error = _g[0], setError = _g[1]; |
@@ -14,2 +14,12 @@ 'use strict'; | ||
}; | ||
// @ts-ignore | ||
localStorage = localStorage || wx.getStorageSync || { | ||
getItem: function () { }, | ||
setItem: function () { } | ||
}; | ||
// @ts-ignore | ||
sessionStorage = sessionStorage || wx.getStorageSync || { | ||
getItem: function () { }, | ||
setItem: function () { } | ||
}; | ||
function createApiHooks(request) { | ||
@@ -21,5 +31,5 @@ var getRequestString = function (params) { | ||
var _b = _a === void 0 ? {} : _a, _c = _b.cache, cache = _c === void 0 ? true : _c, _d = _b.initValue, initValue = _d === void 0 ? {} : _d, params = _b.params, _e = _b.needInit, needInit = _e === void 0 ? true : _e, _f = _b.deepCache, deepCache = _f === void 0 ? false : _f, debounceInterval = _b.debounceInterval; | ||
initValue = cache === 'local' ? localStorage.getItem(getRequestString(params)) : cache === 'session' ? sessionStorage.getItem(getRequestString(params)) : cache | ||
? createApiHooksConfig.getCacheFn(getRequestString(params)) || initValue | ||
: initValue; | ||
initValue = (cache === 'local' ? localStorage.getItem(getRequestString(params)) : cache === 'session' ? sessionStorage.getItem(getRequestString(params)) : cache | ||
&& createApiHooksConfig.getCacheFn(getRequestString(params))) | ||
|| initValue; | ||
var initValueRef = react.useRef(initValue); | ||
@@ -26,0 +36,0 @@ var _g = react.useState(), error = _g[0], setError = _g[1]; |
{ | ||
"name": "create-api-hooks", | ||
"version": "0.0.41", | ||
"version": "0.0.42", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "author": "mushan0x0", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
41785
350