floppy-disk 1.2.0-beta.1 → 1.2.0-beta.2

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.
@@ -104,11 +104,11 @@ export type CreateQueryOptions<TKey extends StoreKey = StoreKey, TResponse = any
104
104
  */
105
105
  staleTime?: number;
106
106
  /**
107
- * Number of maximum retries.
107
+ * Number of maximum error retries.
108
108
  *
109
109
  * Defaults to `1`.
110
110
  */
111
- maxRetryCount?: number | ((error: TError, key: TKey) => number);
111
+ retry?: number | ((error: TError, key: TKey) => number);
112
112
  /**
113
113
  * Auto call the query when the component is mounted.
114
114
  *
@@ -37,7 +37,7 @@ const useQueryDefaultDeps = (state) => [
37
37
  state.hasNextPage,
38
38
  ];
39
39
  export const createQuery = (queryFn, options = {}) => {
40
- const { onFirstSubscribe = noop, onSubscribe = noop, onLastUnsubscribe = noop, onBeforeChangeKey = noop, defaultDeps = useQueryDefaultDeps, select = identityFn, staleTime = DEFAULT_STALE_TIME, maxRetryCount = 1, fetchOnMount = true, fetchOnWindowFocus = true, enabled = true, keepPreviousData, getNextPageParam = () => undefined, onSuccess = noop, onError = noop, onSettled = noop, ...createStoresOptions } = options;
40
+ const { onFirstSubscribe = noop, onSubscribe = noop, onLastUnsubscribe = noop, onBeforeChangeKey = noop, defaultDeps = useQueryDefaultDeps, select = identityFn, staleTime = DEFAULT_STALE_TIME, retry = 1, fetchOnMount = true, fetchOnWindowFocus = true, enabled = true, keepPreviousData, getNextPageParam = () => undefined, onSuccess = noop, onError = noop, onSettled = noop, ...createStoresOptions } = options;
41
41
  const useQuery = createStores(({ key: _key, get, set }) => {
42
42
  const key = _key;
43
43
  const forceFetch = () => {
@@ -116,7 +116,7 @@ export const createQuery = (queryFn, options = {}) => {
116
116
  pageParam,
117
117
  hasNextPage: pageParam !== undefined,
118
118
  });
119
- const retryCount = typeof maxRetryCount === 'function' ? maxRetryCount(error, key) : maxRetryCount;
119
+ const retryCount = typeof retry === 'function' ? retry(error, key) : retry;
120
120
  if (typeof retryCount === 'number' && prevState.retryCount < retryCount) {
121
121
  set({ retryCount: prevState.retryCount + 1, isGoingToRetry: true });
122
122
  callQuery();
@@ -104,11 +104,11 @@ export type CreateQueryOptions<TKey extends StoreKey = StoreKey, TResponse = any
104
104
  */
105
105
  staleTime?: number;
106
106
  /**
107
- * Number of maximum retries.
107
+ * Number of maximum error retries.
108
108
  *
109
109
  * Defaults to `1`.
110
110
  */
111
- maxRetryCount?: number | ((error: TError, key: TKey) => number);
111
+ retry?: number | ((error: TError, key: TKey) => number);
112
112
  /**
113
113
  * Auto call the query when the component is mounted.
114
114
  *
@@ -40,7 +40,7 @@ const useQueryDefaultDeps = (state) => [
40
40
  state.hasNextPage,
41
41
  ];
42
42
  const createQuery = (queryFn, options = {}) => {
43
- const { onFirstSubscribe = utils_1.noop, onSubscribe = utils_1.noop, onLastUnsubscribe = utils_1.noop, onBeforeChangeKey = utils_1.noop, defaultDeps = useQueryDefaultDeps, select = utils_1.identityFn, staleTime = DEFAULT_STALE_TIME, maxRetryCount = 1, fetchOnMount = true, fetchOnWindowFocus = true, enabled = true, keepPreviousData, getNextPageParam = () => undefined, onSuccess = utils_1.noop, onError = utils_1.noop, onSettled = utils_1.noop, ...createStoresOptions } = options;
43
+ const { onFirstSubscribe = utils_1.noop, onSubscribe = utils_1.noop, onLastUnsubscribe = utils_1.noop, onBeforeChangeKey = utils_1.noop, defaultDeps = useQueryDefaultDeps, select = utils_1.identityFn, staleTime = DEFAULT_STALE_TIME, retry = 1, fetchOnMount = true, fetchOnWindowFocus = true, enabled = true, keepPreviousData, getNextPageParam = () => undefined, onSuccess = utils_1.noop, onError = utils_1.noop, onSettled = utils_1.noop, ...createStoresOptions } = options;
44
44
  const useQuery = (0, create_stores_1.createStores)(({ key: _key, get, set }) => {
45
45
  const key = _key;
46
46
  const forceFetch = () => {
@@ -119,7 +119,7 @@ const createQuery = (queryFn, options = {}) => {
119
119
  pageParam,
120
120
  hasNextPage: pageParam !== undefined,
121
121
  });
122
- const retryCount = typeof maxRetryCount === 'function' ? maxRetryCount(error, key) : maxRetryCount;
122
+ const retryCount = typeof retry === 'function' ? retry(error, key) : retry;
123
123
  if (typeof retryCount === 'number' && prevState.retryCount < retryCount) {
124
124
  set({ retryCount: prevState.retryCount + 1, isGoingToRetry: true });
125
125
  callQuery();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "floppy-disk",
3
- "version": "1.2.0-beta.1",
3
+ "version": "1.2.0-beta.2",
4
4
  "description": "FloppyDisk - lightweight, simple, and powerful state management library",
5
5
  "keywords": [
6
6
  "state",