floppy-disk 2.5.0 → 2.6.0-beta.1
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 +1 -1
- package/esm/preact/create-query.js +9 -8
- package/esm/react/create-query.d.ts +1 -1
- package/esm/react/create-query.js +9 -8
- package/lib/preact/create-query.d.ts +1 -1
- package/lib/preact/create-query.js +9 -8
- package/lib/react/create-query.d.ts +1 -1
- package/lib/react/create-query.js +9 -8
- package/package.json +1 -1
|
@@ -191,7 +191,7 @@ export type CreateQueryOptions<TKey extends StoreKey = StoreKey, TResponse = any
|
|
|
191
191
|
*
|
|
192
192
|
* This function should return a variable that will be stored as `pageParam` that can be used when fetching next page.
|
|
193
193
|
*/
|
|
194
|
-
getNextPageParam?: (lastPage: TResponse, index: number) => Maybe<TPageParam>;
|
|
194
|
+
getNextPageParam?: (lastPage: TResponse, index: number, stateBeforeCallQuery: QueryState<TKey, TResponse, TData, TError, TPageParam>) => Maybe<TPageParam>;
|
|
195
195
|
onBeforeFetch?: (cancel: () => void, state: QueryState<TKey, TResponse, TData, TError, TPageParam>) => void;
|
|
196
196
|
onSuccess?: (response: TResponse, stateBeforeCallQuery: QueryState<TKey, TResponse, TData, TError, TPageParam>) => void;
|
|
197
197
|
onError?: (error: TError, stateBeforeCallQuery: QueryState<TKey, TResponse, TData, TError, TPageParam>) => void;
|
|
@@ -55,11 +55,11 @@ export const createQuery = (queryFn, options = {}) => {
|
|
|
55
55
|
};
|
|
56
56
|
const forceFetch = () => new Promise((resolve) => {
|
|
57
57
|
const state = get();
|
|
58
|
+
const { isWaiting, isLoading, pageParams } = state;
|
|
58
59
|
const responseAllPages = [];
|
|
59
|
-
const newPageParams = [
|
|
60
|
-
let pageParam =
|
|
60
|
+
const newPageParams = [pageParams[0]];
|
|
61
|
+
let pageParam = pageParams[0];
|
|
61
62
|
clearTimeout(refetchIntervalTimeoutId.get(keyHash));
|
|
62
|
-
const { isWaiting, isLoading, pageParams } = state;
|
|
63
63
|
if (isWaiting || !getValueOrComputedValue(enabled, key))
|
|
64
64
|
return resolve(state);
|
|
65
65
|
let shouldcancel = false;
|
|
@@ -81,8 +81,8 @@ export const createQuery = (queryFn, options = {}) => {
|
|
|
81
81
|
set({ isGoingToRetry: false, isWaiting: true, isRefetching: true });
|
|
82
82
|
clearTimeout(retryTimeoutId.get(keyHash));
|
|
83
83
|
}
|
|
84
|
-
const stateBeforeCallQuery = { ...get(), pageParam };
|
|
85
84
|
preventReplaceResponse.set(keyHash, false);
|
|
85
|
+
const stateBeforeCallQuery = { ...get(), pageParam };
|
|
86
86
|
queryFn(key, stateBeforeCallQuery)
|
|
87
87
|
.then((response) => {
|
|
88
88
|
if (preventReplaceResponse.get(keyHash)) {
|
|
@@ -90,7 +90,7 @@ export const createQuery = (queryFn, options = {}) => {
|
|
|
90
90
|
return resolve(get());
|
|
91
91
|
}
|
|
92
92
|
responseAllPages.push(response);
|
|
93
|
-
const newPageParam = getNextPageParam(response, responseAllPages.length);
|
|
93
|
+
const newPageParam = getNextPageParam(response, responseAllPages.length, stateBeforeCallQuery);
|
|
94
94
|
newPageParams.push(newPageParam);
|
|
95
95
|
if (hasValue(newPageParam) && newPageParams.length < pageParams.length) {
|
|
96
96
|
pageParam = newPageParam;
|
|
@@ -206,7 +206,7 @@ export const createQuery = (queryFn, options = {}) => {
|
|
|
206
206
|
const stateBeforeCallQuery = get();
|
|
207
207
|
queryFn(key, { ...state, pageParam })
|
|
208
208
|
.then((response) => {
|
|
209
|
-
const newPageParam = getNextPageParam(response, pageParams.length);
|
|
209
|
+
const newPageParam = getNextPageParam(response, pageParams.length, stateBeforeCallQuery);
|
|
210
210
|
set({
|
|
211
211
|
isWaitingNextPage: false,
|
|
212
212
|
response,
|
|
@@ -327,9 +327,10 @@ export const createQuery = (queryFn, options = {}) => {
|
|
|
327
327
|
useQuery.setInitialResponse = ({ key, response, skipRevalidation }) => {
|
|
328
328
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
329
329
|
useState(() => {
|
|
330
|
-
|
|
330
|
+
const state = useQuery.get(key);
|
|
331
|
+
if (response === undefined || state.isSuccess)
|
|
331
332
|
return;
|
|
332
|
-
const newPageParam = getNextPageParam(response, 1);
|
|
333
|
+
const newPageParam = getNextPageParam(response, 1, state);
|
|
333
334
|
useQuery.set(key, {
|
|
334
335
|
status: 'success',
|
|
335
336
|
isLoading: false,
|
|
@@ -190,7 +190,7 @@ export type CreateQueryOptions<TKey extends StoreKey = StoreKey, TResponse = any
|
|
|
190
190
|
*
|
|
191
191
|
* This function should return a variable that will be stored as `pageParam` that can be used when fetching next page.
|
|
192
192
|
*/
|
|
193
|
-
getNextPageParam?: (lastPage: TResponse, index: number) => Maybe<TPageParam>;
|
|
193
|
+
getNextPageParam?: (lastPage: TResponse, index: number, stateBeforeCallQuery: QueryState<TKey, TResponse, TData, TError, TPageParam>) => Maybe<TPageParam>;
|
|
194
194
|
onBeforeFetch?: (cancel: () => void, state: QueryState<TKey, TResponse, TData, TError, TPageParam>) => void;
|
|
195
195
|
onSuccess?: (response: TResponse, stateBeforeCallQuery: QueryState<TKey, TResponse, TData, TError, TPageParam>) => void;
|
|
196
196
|
onError?: (error: TError, stateBeforeCallQuery: QueryState<TKey, TResponse, TData, TError, TPageParam>) => void;
|
|
@@ -54,11 +54,11 @@ export const createQuery = (queryFn, options = {}) => {
|
|
|
54
54
|
};
|
|
55
55
|
const forceFetch = () => new Promise((resolve) => {
|
|
56
56
|
const state = get();
|
|
57
|
+
const { isWaiting, isLoading, pageParams } = state;
|
|
57
58
|
const responseAllPages = [];
|
|
58
|
-
const newPageParams = [
|
|
59
|
-
let pageParam =
|
|
59
|
+
const newPageParams = [pageParams[0]];
|
|
60
|
+
let pageParam = pageParams[0];
|
|
60
61
|
clearTimeout(refetchIntervalTimeoutId.get(keyHash));
|
|
61
|
-
const { isWaiting, isLoading, pageParams } = state;
|
|
62
62
|
if (isWaiting || !getValueOrComputedValue(enabled, key))
|
|
63
63
|
return resolve(state);
|
|
64
64
|
let shouldcancel = false;
|
|
@@ -80,8 +80,8 @@ export const createQuery = (queryFn, options = {}) => {
|
|
|
80
80
|
set({ isGoingToRetry: false, isWaiting: true, isRefetching: true });
|
|
81
81
|
clearTimeout(retryTimeoutId.get(keyHash));
|
|
82
82
|
}
|
|
83
|
-
const stateBeforeCallQuery = { ...get(), pageParam };
|
|
84
83
|
preventReplaceResponse.set(keyHash, false);
|
|
84
|
+
const stateBeforeCallQuery = { ...get(), pageParam };
|
|
85
85
|
queryFn(key, stateBeforeCallQuery)
|
|
86
86
|
.then((response) => {
|
|
87
87
|
if (preventReplaceResponse.get(keyHash)) {
|
|
@@ -89,7 +89,7 @@ export const createQuery = (queryFn, options = {}) => {
|
|
|
89
89
|
return resolve(get());
|
|
90
90
|
}
|
|
91
91
|
responseAllPages.push(response);
|
|
92
|
-
const newPageParam = getNextPageParam(response, responseAllPages.length);
|
|
92
|
+
const newPageParam = getNextPageParam(response, responseAllPages.length, stateBeforeCallQuery);
|
|
93
93
|
newPageParams.push(newPageParam);
|
|
94
94
|
if (hasValue(newPageParam) && newPageParams.length < pageParams.length) {
|
|
95
95
|
pageParam = newPageParam;
|
|
@@ -205,7 +205,7 @@ export const createQuery = (queryFn, options = {}) => {
|
|
|
205
205
|
const stateBeforeCallQuery = get();
|
|
206
206
|
queryFn(key, { ...state, pageParam })
|
|
207
207
|
.then((response) => {
|
|
208
|
-
const newPageParam = getNextPageParam(response, pageParams.length);
|
|
208
|
+
const newPageParam = getNextPageParam(response, pageParams.length, stateBeforeCallQuery);
|
|
209
209
|
set({
|
|
210
210
|
isWaitingNextPage: false,
|
|
211
211
|
response,
|
|
@@ -326,9 +326,10 @@ export const createQuery = (queryFn, options = {}) => {
|
|
|
326
326
|
useQuery.setInitialResponse = ({ key, response, skipRevalidation }) => {
|
|
327
327
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
328
328
|
useState(() => {
|
|
329
|
-
|
|
329
|
+
const state = useQuery.get(key);
|
|
330
|
+
if (response === undefined || state.isSuccess)
|
|
330
331
|
return;
|
|
331
|
-
const newPageParam = getNextPageParam(response, 1);
|
|
332
|
+
const newPageParam = getNextPageParam(response, 1, state);
|
|
332
333
|
useQuery.set(key, {
|
|
333
334
|
status: 'success',
|
|
334
335
|
isLoading: false,
|
|
@@ -191,7 +191,7 @@ export type CreateQueryOptions<TKey extends StoreKey = StoreKey, TResponse = any
|
|
|
191
191
|
*
|
|
192
192
|
* This function should return a variable that will be stored as `pageParam` that can be used when fetching next page.
|
|
193
193
|
*/
|
|
194
|
-
getNextPageParam?: (lastPage: TResponse, index: number) => Maybe<TPageParam>;
|
|
194
|
+
getNextPageParam?: (lastPage: TResponse, index: number, stateBeforeCallQuery: QueryState<TKey, TResponse, TData, TError, TPageParam>) => Maybe<TPageParam>;
|
|
195
195
|
onBeforeFetch?: (cancel: () => void, state: QueryState<TKey, TResponse, TData, TError, TPageParam>) => void;
|
|
196
196
|
onSuccess?: (response: TResponse, stateBeforeCallQuery: QueryState<TKey, TResponse, TData, TError, TPageParam>) => void;
|
|
197
197
|
onError?: (error: TError, stateBeforeCallQuery: QueryState<TKey, TResponse, TData, TError, TPageParam>) => void;
|
|
@@ -58,11 +58,11 @@ const createQuery = (queryFn, options = {}) => {
|
|
|
58
58
|
};
|
|
59
59
|
const forceFetch = () => new Promise((resolve) => {
|
|
60
60
|
const state = get();
|
|
61
|
+
const { isWaiting, isLoading, pageParams } = state;
|
|
61
62
|
const responseAllPages = [];
|
|
62
|
-
const newPageParams = [
|
|
63
|
-
let pageParam =
|
|
63
|
+
const newPageParams = [pageParams[0]];
|
|
64
|
+
let pageParam = pageParams[0];
|
|
64
65
|
clearTimeout(refetchIntervalTimeoutId.get(keyHash));
|
|
65
|
-
const { isWaiting, isLoading, pageParams } = state;
|
|
66
66
|
if (isWaiting || !(0, utils_1.getValueOrComputedValue)(enabled, key))
|
|
67
67
|
return resolve(state);
|
|
68
68
|
let shouldcancel = false;
|
|
@@ -84,8 +84,8 @@ const createQuery = (queryFn, options = {}) => {
|
|
|
84
84
|
set({ isGoingToRetry: false, isWaiting: true, isRefetching: true });
|
|
85
85
|
clearTimeout(retryTimeoutId.get(keyHash));
|
|
86
86
|
}
|
|
87
|
-
const stateBeforeCallQuery = { ...get(), pageParam };
|
|
88
87
|
preventReplaceResponse.set(keyHash, false);
|
|
88
|
+
const stateBeforeCallQuery = { ...get(), pageParam };
|
|
89
89
|
queryFn(key, stateBeforeCallQuery)
|
|
90
90
|
.then((response) => {
|
|
91
91
|
if (preventReplaceResponse.get(keyHash)) {
|
|
@@ -93,7 +93,7 @@ const createQuery = (queryFn, options = {}) => {
|
|
|
93
93
|
return resolve(get());
|
|
94
94
|
}
|
|
95
95
|
responseAllPages.push(response);
|
|
96
|
-
const newPageParam = getNextPageParam(response, responseAllPages.length);
|
|
96
|
+
const newPageParam = getNextPageParam(response, responseAllPages.length, stateBeforeCallQuery);
|
|
97
97
|
newPageParams.push(newPageParam);
|
|
98
98
|
if ((0, utils_1.hasValue)(newPageParam) && newPageParams.length < pageParams.length) {
|
|
99
99
|
pageParam = newPageParam;
|
|
@@ -209,7 +209,7 @@ const createQuery = (queryFn, options = {}) => {
|
|
|
209
209
|
const stateBeforeCallQuery = get();
|
|
210
210
|
queryFn(key, { ...state, pageParam })
|
|
211
211
|
.then((response) => {
|
|
212
|
-
const newPageParam = getNextPageParam(response, pageParams.length);
|
|
212
|
+
const newPageParam = getNextPageParam(response, pageParams.length, stateBeforeCallQuery);
|
|
213
213
|
set({
|
|
214
214
|
isWaitingNextPage: false,
|
|
215
215
|
response,
|
|
@@ -330,9 +330,10 @@ const createQuery = (queryFn, options = {}) => {
|
|
|
330
330
|
useQuery.setInitialResponse = ({ key, response, skipRevalidation }) => {
|
|
331
331
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
332
332
|
(0, hooks_1.useState)(() => {
|
|
333
|
-
|
|
333
|
+
const state = useQuery.get(key);
|
|
334
|
+
if (response === undefined || state.isSuccess)
|
|
334
335
|
return;
|
|
335
|
-
const newPageParam = getNextPageParam(response, 1);
|
|
336
|
+
const newPageParam = getNextPageParam(response, 1, state);
|
|
336
337
|
useQuery.set(key, {
|
|
337
338
|
status: 'success',
|
|
338
339
|
isLoading: false,
|
|
@@ -190,7 +190,7 @@ export type CreateQueryOptions<TKey extends StoreKey = StoreKey, TResponse = any
|
|
|
190
190
|
*
|
|
191
191
|
* This function should return a variable that will be stored as `pageParam` that can be used when fetching next page.
|
|
192
192
|
*/
|
|
193
|
-
getNextPageParam?: (lastPage: TResponse, index: number) => Maybe<TPageParam>;
|
|
193
|
+
getNextPageParam?: (lastPage: TResponse, index: number, stateBeforeCallQuery: QueryState<TKey, TResponse, TData, TError, TPageParam>) => Maybe<TPageParam>;
|
|
194
194
|
onBeforeFetch?: (cancel: () => void, state: QueryState<TKey, TResponse, TData, TError, TPageParam>) => void;
|
|
195
195
|
onSuccess?: (response: TResponse, stateBeforeCallQuery: QueryState<TKey, TResponse, TData, TError, TPageParam>) => void;
|
|
196
196
|
onError?: (error: TError, stateBeforeCallQuery: QueryState<TKey, TResponse, TData, TError, TPageParam>) => void;
|
|
@@ -57,11 +57,11 @@ const createQuery = (queryFn, options = {}) => {
|
|
|
57
57
|
};
|
|
58
58
|
const forceFetch = () => new Promise((resolve) => {
|
|
59
59
|
const state = get();
|
|
60
|
+
const { isWaiting, isLoading, pageParams } = state;
|
|
60
61
|
const responseAllPages = [];
|
|
61
|
-
const newPageParams = [
|
|
62
|
-
let pageParam =
|
|
62
|
+
const newPageParams = [pageParams[0]];
|
|
63
|
+
let pageParam = pageParams[0];
|
|
63
64
|
clearTimeout(refetchIntervalTimeoutId.get(keyHash));
|
|
64
|
-
const { isWaiting, isLoading, pageParams } = state;
|
|
65
65
|
if (isWaiting || !(0, utils_1.getValueOrComputedValue)(enabled, key))
|
|
66
66
|
return resolve(state);
|
|
67
67
|
let shouldcancel = false;
|
|
@@ -83,8 +83,8 @@ const createQuery = (queryFn, options = {}) => {
|
|
|
83
83
|
set({ isGoingToRetry: false, isWaiting: true, isRefetching: true });
|
|
84
84
|
clearTimeout(retryTimeoutId.get(keyHash));
|
|
85
85
|
}
|
|
86
|
-
const stateBeforeCallQuery = { ...get(), pageParam };
|
|
87
86
|
preventReplaceResponse.set(keyHash, false);
|
|
87
|
+
const stateBeforeCallQuery = { ...get(), pageParam };
|
|
88
88
|
queryFn(key, stateBeforeCallQuery)
|
|
89
89
|
.then((response) => {
|
|
90
90
|
if (preventReplaceResponse.get(keyHash)) {
|
|
@@ -92,7 +92,7 @@ const createQuery = (queryFn, options = {}) => {
|
|
|
92
92
|
return resolve(get());
|
|
93
93
|
}
|
|
94
94
|
responseAllPages.push(response);
|
|
95
|
-
const newPageParam = getNextPageParam(response, responseAllPages.length);
|
|
95
|
+
const newPageParam = getNextPageParam(response, responseAllPages.length, stateBeforeCallQuery);
|
|
96
96
|
newPageParams.push(newPageParam);
|
|
97
97
|
if ((0, utils_1.hasValue)(newPageParam) && newPageParams.length < pageParams.length) {
|
|
98
98
|
pageParam = newPageParam;
|
|
@@ -208,7 +208,7 @@ const createQuery = (queryFn, options = {}) => {
|
|
|
208
208
|
const stateBeforeCallQuery = get();
|
|
209
209
|
queryFn(key, { ...state, pageParam })
|
|
210
210
|
.then((response) => {
|
|
211
|
-
const newPageParam = getNextPageParam(response, pageParams.length);
|
|
211
|
+
const newPageParam = getNextPageParam(response, pageParams.length, stateBeforeCallQuery);
|
|
212
212
|
set({
|
|
213
213
|
isWaitingNextPage: false,
|
|
214
214
|
response,
|
|
@@ -329,9 +329,10 @@ const createQuery = (queryFn, options = {}) => {
|
|
|
329
329
|
useQuery.setInitialResponse = ({ key, response, skipRevalidation }) => {
|
|
330
330
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
331
331
|
(0, react_1.useState)(() => {
|
|
332
|
-
|
|
332
|
+
const state = useQuery.get(key);
|
|
333
|
+
if (response === undefined || state.isSuccess)
|
|
333
334
|
return;
|
|
334
|
-
const newPageParam = getNextPageParam(response, 1);
|
|
335
|
+
const newPageParam = getNextPageParam(response, 1, state);
|
|
335
336
|
useQuery.set(key, {
|
|
336
337
|
status: 'success',
|
|
337
338
|
isLoading: false,
|