floppy-disk 2.2.0-beta.1 → 2.2.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/preact/create-query.d.ts +6 -3
- package/esm/preact/create-query.js +4 -3
- package/esm/react/create-query.d.ts +6 -3
- package/esm/react/create-query.js +4 -3
- package/lib/preact/create-query.d.ts +6 -3
- package/lib/preact/create-query.js +4 -3
- package/lib/react/create-query.d.ts +6 -3
- package/lib/react/create-query.js +4 -3
- package/package.json +1 -1
|
@@ -132,7 +132,10 @@ export type CreateQueryOptions<TKey extends StoreKey = StoreKey, TResponse = any
|
|
|
132
132
|
*/
|
|
133
133
|
fetchOnMount?: boolean | 'always' | ((key: TKey) => boolean | 'always');
|
|
134
134
|
/**
|
|
135
|
-
* Defaults to `
|
|
135
|
+
* Defaults to follow the value of `fetchOnMount`.
|
|
136
|
+
*
|
|
137
|
+
* `fetchOnMount` and `fetchOnWindowFocus` can be set to different values.
|
|
138
|
+
* However, if `fetchOnWindowFocus` is not explicitly set, it will mimic the value of `fetchOnMount`.
|
|
136
139
|
*
|
|
137
140
|
* - If set to `true`, the query will be called on window focus **if the data is stale**.
|
|
138
141
|
* - If set to `false`, the query won't be called on window focus.
|
|
@@ -152,13 +155,13 @@ export type CreateQueryOptions<TKey extends StoreKey = StoreKey, TResponse = any
|
|
|
152
155
|
*
|
|
153
156
|
* Defaults to `1`.
|
|
154
157
|
*/
|
|
155
|
-
retry?: number | ((error: TError,
|
|
158
|
+
retry?: number | ((error: TError, prevState: QueryState<TKey, TResponse, TData, TError>) => number);
|
|
156
159
|
/**
|
|
157
160
|
* Error retry delay in miliseconds.
|
|
158
161
|
*
|
|
159
162
|
* Defaults to `2000` (2 seconds).
|
|
160
163
|
*/
|
|
161
|
-
retryDelay?: number | ((error: TError,
|
|
164
|
+
retryDelay?: number | ((error: TError, prevState: QueryState<TKey, TResponse, TData, TError>) => number);
|
|
162
165
|
/**
|
|
163
166
|
* If set to `true`, previous `data` will be kept when fetching new data because the query key changed.
|
|
164
167
|
*
|
|
@@ -40,7 +40,7 @@ const useQueryDefaultDeps = (state) => [
|
|
|
40
40
|
state.hasNextPage,
|
|
41
41
|
];
|
|
42
42
|
export const createQuery = (queryFn, options = {}) => {
|
|
43
|
-
const defaultFetchOnWindowFocus = options.fetchOnMount
|
|
43
|
+
const defaultFetchOnWindowFocus = options.fetchOnMount ?? true;
|
|
44
44
|
const { onFirstSubscribe = noop, onSubscribe = noop, onLastUnsubscribe = noop, onBeforeChangeKey = noop, defaultDeps = useQueryDefaultDeps, select = identityFn, staleTime = 3000, // 3 seconds
|
|
45
45
|
fetchOnMount = true, fetchOnWindowFocus = defaultFetchOnWindowFocus, enabled = true, retry = 1, retryDelay = 2000, // 2 seconds
|
|
46
46
|
keepPreviousData, getNextPageParam = () => undefined, onSuccess = noop, onError = noop, onSettled = noop, ...createStoresOptions } = options;
|
|
@@ -50,9 +50,10 @@ export const createQuery = (queryFn, options = {}) => {
|
|
|
50
50
|
const useQuery = createStores(({ get, set, key: _key, keyHash }) => {
|
|
51
51
|
const key = _key;
|
|
52
52
|
const getRetryProps = (error, retryCount) => {
|
|
53
|
-
const
|
|
53
|
+
const prevState = get();
|
|
54
|
+
const maxRetryCount = (typeof retry === 'function' ? retry(error, prevState) : retry) || 0;
|
|
54
55
|
const shouldRetry = retryCount < maxRetryCount;
|
|
55
|
-
const delay = (typeof retryDelay === 'function' ? retryDelay(error,
|
|
56
|
+
const delay = (typeof retryDelay === 'function' ? retryDelay(error, prevState) : retryDelay) || 0;
|
|
56
57
|
return { shouldRetry, delay };
|
|
57
58
|
};
|
|
58
59
|
const forceFetch = () => {
|
|
@@ -132,7 +132,10 @@ export type CreateQueryOptions<TKey extends StoreKey = StoreKey, TResponse = any
|
|
|
132
132
|
*/
|
|
133
133
|
fetchOnMount?: boolean | 'always' | ((key: TKey) => boolean | 'always');
|
|
134
134
|
/**
|
|
135
|
-
* Defaults to `
|
|
135
|
+
* Defaults to follow the value of `fetchOnMount`.
|
|
136
|
+
*
|
|
137
|
+
* `fetchOnMount` and `fetchOnWindowFocus` can be set to different values.
|
|
138
|
+
* However, if `fetchOnWindowFocus` is not explicitly set, it will mimic the value of `fetchOnMount`.
|
|
136
139
|
*
|
|
137
140
|
* - If set to `true`, the query will be called on window focus **if the data is stale**.
|
|
138
141
|
* - If set to `false`, the query won't be called on window focus.
|
|
@@ -152,13 +155,13 @@ export type CreateQueryOptions<TKey extends StoreKey = StoreKey, TResponse = any
|
|
|
152
155
|
*
|
|
153
156
|
* Defaults to `1`.
|
|
154
157
|
*/
|
|
155
|
-
retry?: number | ((error: TError,
|
|
158
|
+
retry?: number | ((error: TError, prevState: QueryState<TKey, TResponse, TData, TError>) => number);
|
|
156
159
|
/**
|
|
157
160
|
* Error retry delay in miliseconds.
|
|
158
161
|
*
|
|
159
162
|
* Defaults to `2000` (2 seconds).
|
|
160
163
|
*/
|
|
161
|
-
retryDelay?: number | ((error: TError,
|
|
164
|
+
retryDelay?: number | ((error: TError, prevState: QueryState<TKey, TResponse, TData, TError>) => number);
|
|
162
165
|
/**
|
|
163
166
|
* If set to `true`, previous `data` will be kept when fetching new data because the query key changed.
|
|
164
167
|
*
|
|
@@ -40,7 +40,7 @@ const useQueryDefaultDeps = (state) => [
|
|
|
40
40
|
state.hasNextPage,
|
|
41
41
|
];
|
|
42
42
|
export const createQuery = (queryFn, options = {}) => {
|
|
43
|
-
const defaultFetchOnWindowFocus = options.fetchOnMount
|
|
43
|
+
const defaultFetchOnWindowFocus = options.fetchOnMount ?? true;
|
|
44
44
|
const { onFirstSubscribe = noop, onSubscribe = noop, onLastUnsubscribe = noop, onBeforeChangeKey = noop, defaultDeps = useQueryDefaultDeps, select = identityFn, staleTime = 3000, // 3 seconds
|
|
45
45
|
fetchOnMount = true, fetchOnWindowFocus = defaultFetchOnWindowFocus, enabled = true, retry = 1, retryDelay = 2000, // 2 seconds
|
|
46
46
|
keepPreviousData, getNextPageParam = () => undefined, onSuccess = noop, onError = noop, onSettled = noop, ...createStoresOptions } = options;
|
|
@@ -50,9 +50,10 @@ export const createQuery = (queryFn, options = {}) => {
|
|
|
50
50
|
const useQuery = createStores(({ get, set, key: _key, keyHash }) => {
|
|
51
51
|
const key = _key;
|
|
52
52
|
const getRetryProps = (error, retryCount) => {
|
|
53
|
-
const
|
|
53
|
+
const prevState = get();
|
|
54
|
+
const maxRetryCount = (typeof retry === 'function' ? retry(error, prevState) : retry) || 0;
|
|
54
55
|
const shouldRetry = retryCount < maxRetryCount;
|
|
55
|
-
const delay = (typeof retryDelay === 'function' ? retryDelay(error,
|
|
56
|
+
const delay = (typeof retryDelay === 'function' ? retryDelay(error, prevState) : retryDelay) || 0;
|
|
56
57
|
return { shouldRetry, delay };
|
|
57
58
|
};
|
|
58
59
|
const forceFetch = () => {
|
|
@@ -132,7 +132,10 @@ export type CreateQueryOptions<TKey extends StoreKey = StoreKey, TResponse = any
|
|
|
132
132
|
*/
|
|
133
133
|
fetchOnMount?: boolean | 'always' | ((key: TKey) => boolean | 'always');
|
|
134
134
|
/**
|
|
135
|
-
* Defaults to `
|
|
135
|
+
* Defaults to follow the value of `fetchOnMount`.
|
|
136
|
+
*
|
|
137
|
+
* `fetchOnMount` and `fetchOnWindowFocus` can be set to different values.
|
|
138
|
+
* However, if `fetchOnWindowFocus` is not explicitly set, it will mimic the value of `fetchOnMount`.
|
|
136
139
|
*
|
|
137
140
|
* - If set to `true`, the query will be called on window focus **if the data is stale**.
|
|
138
141
|
* - If set to `false`, the query won't be called on window focus.
|
|
@@ -152,13 +155,13 @@ export type CreateQueryOptions<TKey extends StoreKey = StoreKey, TResponse = any
|
|
|
152
155
|
*
|
|
153
156
|
* Defaults to `1`.
|
|
154
157
|
*/
|
|
155
|
-
retry?: number | ((error: TError,
|
|
158
|
+
retry?: number | ((error: TError, prevState: QueryState<TKey, TResponse, TData, TError>) => number);
|
|
156
159
|
/**
|
|
157
160
|
* Error retry delay in miliseconds.
|
|
158
161
|
*
|
|
159
162
|
* Defaults to `2000` (2 seconds).
|
|
160
163
|
*/
|
|
161
|
-
retryDelay?: number | ((error: TError,
|
|
164
|
+
retryDelay?: number | ((error: TError, prevState: QueryState<TKey, TResponse, TData, TError>) => number);
|
|
162
165
|
/**
|
|
163
166
|
* If set to `true`, previous `data` will be kept when fetching new data because the query key changed.
|
|
164
167
|
*
|
|
@@ -43,7 +43,7 @@ const useQueryDefaultDeps = (state) => [
|
|
|
43
43
|
state.hasNextPage,
|
|
44
44
|
];
|
|
45
45
|
const createQuery = (queryFn, options = {}) => {
|
|
46
|
-
const defaultFetchOnWindowFocus = options.fetchOnMount
|
|
46
|
+
const defaultFetchOnWindowFocus = options.fetchOnMount ?? true;
|
|
47
47
|
const { onFirstSubscribe = utils_1.noop, onSubscribe = utils_1.noop, onLastUnsubscribe = utils_1.noop, onBeforeChangeKey = utils_1.noop, defaultDeps = useQueryDefaultDeps, select = utils_1.identityFn, staleTime = 3000, // 3 seconds
|
|
48
48
|
fetchOnMount = true, fetchOnWindowFocus = defaultFetchOnWindowFocus, enabled = true, retry = 1, retryDelay = 2000, // 2 seconds
|
|
49
49
|
keepPreviousData, getNextPageParam = () => undefined, onSuccess = utils_1.noop, onError = utils_1.noop, onSettled = utils_1.noop, ...createStoresOptions } = options;
|
|
@@ -53,9 +53,10 @@ const createQuery = (queryFn, options = {}) => {
|
|
|
53
53
|
const useQuery = (0, create_stores_1.createStores)(({ get, set, key: _key, keyHash }) => {
|
|
54
54
|
const key = _key;
|
|
55
55
|
const getRetryProps = (error, retryCount) => {
|
|
56
|
-
const
|
|
56
|
+
const prevState = get();
|
|
57
|
+
const maxRetryCount = (typeof retry === 'function' ? retry(error, prevState) : retry) || 0;
|
|
57
58
|
const shouldRetry = retryCount < maxRetryCount;
|
|
58
|
-
const delay = (typeof retryDelay === 'function' ? retryDelay(error,
|
|
59
|
+
const delay = (typeof retryDelay === 'function' ? retryDelay(error, prevState) : retryDelay) || 0;
|
|
59
60
|
return { shouldRetry, delay };
|
|
60
61
|
};
|
|
61
62
|
const forceFetch = () => {
|
|
@@ -132,7 +132,10 @@ export type CreateQueryOptions<TKey extends StoreKey = StoreKey, TResponse = any
|
|
|
132
132
|
*/
|
|
133
133
|
fetchOnMount?: boolean | 'always' | ((key: TKey) => boolean | 'always');
|
|
134
134
|
/**
|
|
135
|
-
* Defaults to `
|
|
135
|
+
* Defaults to follow the value of `fetchOnMount`.
|
|
136
|
+
*
|
|
137
|
+
* `fetchOnMount` and `fetchOnWindowFocus` can be set to different values.
|
|
138
|
+
* However, if `fetchOnWindowFocus` is not explicitly set, it will mimic the value of `fetchOnMount`.
|
|
136
139
|
*
|
|
137
140
|
* - If set to `true`, the query will be called on window focus **if the data is stale**.
|
|
138
141
|
* - If set to `false`, the query won't be called on window focus.
|
|
@@ -152,13 +155,13 @@ export type CreateQueryOptions<TKey extends StoreKey = StoreKey, TResponse = any
|
|
|
152
155
|
*
|
|
153
156
|
* Defaults to `1`.
|
|
154
157
|
*/
|
|
155
|
-
retry?: number | ((error: TError,
|
|
158
|
+
retry?: number | ((error: TError, prevState: QueryState<TKey, TResponse, TData, TError>) => number);
|
|
156
159
|
/**
|
|
157
160
|
* Error retry delay in miliseconds.
|
|
158
161
|
*
|
|
159
162
|
* Defaults to `2000` (2 seconds).
|
|
160
163
|
*/
|
|
161
|
-
retryDelay?: number | ((error: TError,
|
|
164
|
+
retryDelay?: number | ((error: TError, prevState: QueryState<TKey, TResponse, TData, TError>) => number);
|
|
162
165
|
/**
|
|
163
166
|
* If set to `true`, previous `data` will be kept when fetching new data because the query key changed.
|
|
164
167
|
*
|
|
@@ -43,7 +43,7 @@ const useQueryDefaultDeps = (state) => [
|
|
|
43
43
|
state.hasNextPage,
|
|
44
44
|
];
|
|
45
45
|
const createQuery = (queryFn, options = {}) => {
|
|
46
|
-
const defaultFetchOnWindowFocus = options.fetchOnMount
|
|
46
|
+
const defaultFetchOnWindowFocus = options.fetchOnMount ?? true;
|
|
47
47
|
const { onFirstSubscribe = utils_1.noop, onSubscribe = utils_1.noop, onLastUnsubscribe = utils_1.noop, onBeforeChangeKey = utils_1.noop, defaultDeps = useQueryDefaultDeps, select = utils_1.identityFn, staleTime = 3000, // 3 seconds
|
|
48
48
|
fetchOnMount = true, fetchOnWindowFocus = defaultFetchOnWindowFocus, enabled = true, retry = 1, retryDelay = 2000, // 2 seconds
|
|
49
49
|
keepPreviousData, getNextPageParam = () => undefined, onSuccess = utils_1.noop, onError = utils_1.noop, onSettled = utils_1.noop, ...createStoresOptions } = options;
|
|
@@ -53,9 +53,10 @@ const createQuery = (queryFn, options = {}) => {
|
|
|
53
53
|
const useQuery = (0, create_stores_1.createStores)(({ get, set, key: _key, keyHash }) => {
|
|
54
54
|
const key = _key;
|
|
55
55
|
const getRetryProps = (error, retryCount) => {
|
|
56
|
-
const
|
|
56
|
+
const prevState = get();
|
|
57
|
+
const maxRetryCount = (typeof retry === 'function' ? retry(error, prevState) : retry) || 0;
|
|
57
58
|
const shouldRetry = retryCount < maxRetryCount;
|
|
58
|
-
const delay = (typeof retryDelay === 'function' ? retryDelay(error,
|
|
59
|
+
const delay = (typeof retryDelay === 'function' ? retryDelay(error, prevState) : retryDelay) || 0;
|
|
59
60
|
return { shouldRetry, delay };
|
|
60
61
|
};
|
|
61
62
|
const forceFetch = () => {
|