@nanostores/query
Advanced tools
Comparing version 0.3.3 to 0.3.4
@@ -74,2 +74,10 @@ import { PlatformCompat } from './platforms/type'; | ||
}; | ||
/** | ||
* This piece of shenanigans is copy-pasted from SWR. God be my witness I don't like | ||
* all this bitwise shifting operations as they are absolutely unclear, but I'm | ||
* ok to compact the code a bit. | ||
*/ | ||
export declare function defaultOnErrorRetry({ retryCount }: { | ||
retryCount: number; | ||
}): number; | ||
export declare const nanoqueryFactory: ([isAppVisible, visibilityChangeSubscribe, reconnectChangeSubscribe,]: PlatformCompat) => ({ cache, fetcher: globalFetcher, ...globalSettings }?: NanoqueryArgs) => readonly [<T = unknown, E = any>(keyInput: KeyInput, { fetcher, ...fetcherSettings }?: CommonSettings<T>) => FetcherStore<T, E>, <Data = void, Result = unknown, E_1 = any>(mutator: ManualMutator<Data, Result>, opts?: { | ||
@@ -76,0 +84,0 @@ throttleCalls?: boolean; |
export type { KeyInput, KeySelector, Fetcher, OnErrorRetry, CommonSettings, NanoqueryArgs, FetcherValue, FetcherStore, FetcherStoreCreator, ManualMutator, MutateCb, MutatorStore, } from './factory'; | ||
export { defaultOnErrorRetry as onErrorRetry } from './factory'; | ||
export declare const nanoquery: ({ cache, fetcher: globalFetcher, ...globalSettings }?: import('./factory').NanoqueryArgs) => readonly [<T = unknown, E = any>(keyInput: import('./factory').KeyInput, { fetcher, ...fetcherSettings }?: import('./factory').CommonSettings<T>) => import('./factory').FetcherStore<T, E>, <Data = void, Result = unknown, E_1 = any>(mutator: import('./factory').ManualMutator<Data, Result>, opts?: { | ||
@@ -3,0 +4,0 @@ throttleCalls?: boolean | undefined; |
import { map, onStart, onStop, atom, batched, startTask } from 'nanostores'; | ||
import { createNanoEvents } from 'nanoevents'; | ||
function defaultOnErrorRetry({ retryCount }) { | ||
return ~~((Math.random() + 0.5) * (1 << (retryCount < 8 ? retryCount : 8))) * 2e3; | ||
} | ||
const nanoqueryFactory = ([ | ||
@@ -106,3 +109,6 @@ isAppVisible, | ||
key, | ||
setTimeout(() => invalidateKeys(key), timer) | ||
setTimeout(() => { | ||
invalidateKeys(key); | ||
cache.set(key, { retryCount }); | ||
}, timer) | ||
); | ||
@@ -151,5 +157,5 @@ } | ||
const unsub = fetcherStore.listen(({ error, data }) => { | ||
if (error) | ||
if (error !== void 0) | ||
resolve({ error }); | ||
if (data) | ||
if (data !== void 0) | ||
resolve({ data }); | ||
@@ -391,5 +397,2 @@ }); | ||
}; | ||
function defaultOnErrorRetry({ retryCount }) { | ||
return ~~((Math.random() + 0.5) * (1 << (retryCount < 8 ? retryCount : 8))) * 2e3; | ||
} | ||
function noop() { | ||
@@ -426,2 +429,2 @@ } | ||
export { nanoquery }; | ||
export { nanoquery, defaultOnErrorRetry as onErrorRetry }; |
{ | ||
"name": "@nanostores/query", | ||
"version": "0.3.3", | ||
"version": "0.3.4", | ||
"description": "Tiny remote data fetching library for Nano Stores", | ||
@@ -5,0 +5,0 @@ "scripts": { |
@@ -298,3 +298,4 @@ # Nano Stores Query | ||
- it will execute against currently set keys (no way to customize them for the call); | ||
- it will still leverage deduplication. | ||
- it will still leverage deduplication; | ||
- underlying fetcher function cannot resolve or reject with `undefined` as their value. This will lead to hanging promises. | ||
@@ -301,0 +302,0 @@ ### Dependencies, but not in keys |
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
67032
1400
336