floppy-disk 2.4.0-beta.3 → 2.4.0
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-mutation.d.ts +3 -0
- package/esm/preact/create-mutation.js +3 -0
- package/esm/preact/create-query.d.ts +6 -1
- package/esm/preact/create-query.js +3 -0
- package/esm/preact/create-store.d.ts +3 -0
- package/esm/preact/create-store.js +3 -0
- package/esm/preact/create-stores.d.ts +3 -0
- package/esm/preact/create-stores.js +3 -0
- package/esm/react/create-mutation.d.ts +3 -0
- package/esm/react/create-mutation.js +3 -0
- package/esm/react/create-query.d.ts +6 -1
- package/esm/react/create-query.js +3 -0
- package/esm/react/create-store.d.ts +3 -0
- package/esm/react/create-store.js +3 -0
- package/esm/react/create-stores.d.ts +3 -0
- package/esm/react/create-stores.js +3 -0
- package/lib/preact/create-mutation.d.ts +3 -0
- package/lib/preact/create-mutation.js +3 -0
- package/lib/preact/create-query.d.ts +6 -1
- package/lib/preact/create-query.js +3 -0
- package/lib/preact/create-store.d.ts +3 -0
- package/lib/preact/create-store.js +3 -0
- package/lib/preact/create-stores.d.ts +3 -0
- package/lib/preact/create-stores.js +3 -0
- package/lib/react/create-mutation.d.ts +3 -0
- package/lib/react/create-mutation.js +3 -0
- package/lib/react/create-query.d.ts +6 -1
- package/lib/react/create-query.js +3 -0
- package/lib/react/create-store.d.ts +3 -0
- package/lib/react/create-store.js +3 -0
- package/lib/react/create-stores.d.ts +3 -0
- package/lib/react/create-stores.js +3 -0
- package/package.json +1 -1
|
@@ -33,4 +33,7 @@ export type CreateMutationOptions<TVar, TResponse = any, TError = unknown> = Ini
|
|
|
33
33
|
onError?: (error: TError, variables: TVar, stateBeforeMutate: MutationState<TVar, TResponse, TError>) => void;
|
|
34
34
|
onSettled?: (variables: TVar, stateBeforeMutate: MutationState<TVar, TResponse, TError>) => void;
|
|
35
35
|
};
|
|
36
|
+
/**
|
|
37
|
+
* @see https://floppy-disk.vercel.app/docs/api#createmutation
|
|
38
|
+
*/
|
|
36
39
|
export declare const createMutation: <TVar, TResponse = any, TError = unknown>(mutationFn: (variables: TVar, state: MutationState<TVar, TResponse, TError>) => Promise<TResponse>, options?: CreateMutationOptions<TVar, TResponse, TError>) => UseMutation<TVar, TResponse, TError>;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { noop } from '../utils';
|
|
2
2
|
import { createStore } from './create-store';
|
|
3
|
+
/**
|
|
4
|
+
* @see https://floppy-disk.vercel.app/docs/api#createmutation
|
|
5
|
+
*/
|
|
3
6
|
export const createMutation = (mutationFn, options = {}) => {
|
|
4
7
|
const { onMutate = noop, onSuccess = noop, onError = noop, onSettled = noop, ...createStoreOptions } = options;
|
|
5
8
|
const useMutation = createStore(({ set, get }) => ({
|
|
@@ -198,7 +198,9 @@ export type CreateQueryOptions<TKey extends StoreKey = StoreKey, TResponse = any
|
|
|
198
198
|
*
|
|
199
199
|
* Disabled by default.
|
|
200
200
|
*
|
|
201
|
-
* If
|
|
201
|
+
* If last data fetching is failed, the polling interval will be disabled, and it will use `retry` mechanism instead.
|
|
202
|
+
*
|
|
203
|
+
* @see https://floppy-disk.vercel.app/docs/query/polling
|
|
202
204
|
*/
|
|
203
205
|
refetchInterval?: number | false | ((state: QueryState<TKey, TResponse, TData, TError>) => number | false);
|
|
204
206
|
};
|
|
@@ -258,4 +260,7 @@ export type UseQuery<TKey extends StoreKey = StoreKey, TResponse = any, TData =
|
|
|
258
260
|
error?: FunctionComponent<TKey>;
|
|
259
261
|
}) => JSX.Element;
|
|
260
262
|
};
|
|
263
|
+
/**
|
|
264
|
+
* @see https://floppy-disk.vercel.app/docs/api#createquery
|
|
265
|
+
*/
|
|
261
266
|
export declare const createQuery: <TKey extends StoreKey = StoreKey, TResponse = any, TData = TResponse, TError = unknown>(queryFn: (key: TKey, state: QueryState<TKey, TResponse, TData, TError>) => Promise<TResponse>, options?: CreateQueryOptions<TKey, TResponse, TData, TError>) => UseQuery<TKey, TResponse, TData, TError>;
|
|
@@ -32,6 +32,9 @@ const useQueryDefaultDeps = (state) => [
|
|
|
32
32
|
state.isWaitingNextPage,
|
|
33
33
|
state.hasNextPage,
|
|
34
34
|
];
|
|
35
|
+
/**
|
|
36
|
+
* @see https://floppy-disk.vercel.app/docs/api#createquery
|
|
37
|
+
*/
|
|
35
38
|
export const createQuery = (queryFn, options = {}) => {
|
|
36
39
|
const defaultFetchOnWindowFocus = options.fetchOnMount ?? true;
|
|
37
40
|
const { onFirstSubscribe = noop, onSubscribe = noop, onLastUnsubscribe = noop, onBeforeChangeKey = noop, defaultDeps = useQueryDefaultDeps, select = identityFn, staleTime = 3000, // 3 seconds
|
|
@@ -23,6 +23,9 @@ export type UseStore<T extends StoreData> = {
|
|
|
23
23
|
setDefaultValues: (values: SetStoreData<T>) => void;
|
|
24
24
|
Watch: (props: WatchProps<T>) => any;
|
|
25
25
|
};
|
|
26
|
+
/**
|
|
27
|
+
* @see https://floppy-disk.vercel.app/docs/api#createstore
|
|
28
|
+
*/
|
|
26
29
|
export declare const createStore: <T extends StoreData>(initializer: StoreInitializer<T>, options?: InitStoreOptions<T> & {
|
|
27
30
|
defaultDeps?: SelectDeps<T>;
|
|
28
31
|
}) => UseStore<T>;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { useEffect, useState } from 'preact/hooks';
|
|
2
2
|
import { initStore, } from '../vanilla';
|
|
3
|
+
/**
|
|
4
|
+
* @see https://floppy-disk.vercel.app/docs/api#createstore
|
|
5
|
+
*/
|
|
3
6
|
export const createStore = (initializer, options = {}) => {
|
|
4
7
|
const { get, set, subscribe, getSubscribers } = initStore(initializer, options);
|
|
5
8
|
const { defaultDeps } = options;
|
|
@@ -46,5 +46,8 @@ export type CreateStoresOptions<TKey extends StoreKey = StoreKey, T extends Stor
|
|
|
46
46
|
defaultDeps?: SelectDeps<T>;
|
|
47
47
|
hashKeyFn?: (obj: TKey) => string;
|
|
48
48
|
};
|
|
49
|
+
/**
|
|
50
|
+
* @see https://floppy-disk.vercel.app/docs/api#createstores
|
|
51
|
+
*/
|
|
49
52
|
export declare const createStores: <TKey extends StoreKey = StoreKey, T extends StoreData = StoreData>(initializer: StoresInitializer<TKey, T>, options?: CreateStoresOptions<TKey, T>) => UseStores<TKey, T>;
|
|
50
53
|
export {};
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { useEffect, useMemo, useRef, useState } from 'preact/hooks';
|
|
2
2
|
import { hashStoreKey, noop } from '../utils';
|
|
3
3
|
import { initStore, } from '../vanilla';
|
|
4
|
+
/**
|
|
5
|
+
* @see https://floppy-disk.vercel.app/docs/api#createstores
|
|
6
|
+
*/
|
|
4
7
|
export const createStores = (initializer, options = {}) => {
|
|
5
8
|
const { onBeforeChangeKey = noop, onStoreInitialized = noop, defaultDeps, hashKeyFn = hashStoreKey, } = options;
|
|
6
9
|
const stores = new Map();
|
|
@@ -33,4 +33,7 @@ export type CreateMutationOptions<TVar, TResponse = any, TError = unknown> = Ini
|
|
|
33
33
|
onError?: (error: TError, variables: TVar, stateBeforeMutate: MutationState<TVar, TResponse, TError>) => void;
|
|
34
34
|
onSettled?: (variables: TVar, stateBeforeMutate: MutationState<TVar, TResponse, TError>) => void;
|
|
35
35
|
};
|
|
36
|
+
/**
|
|
37
|
+
* @see https://floppy-disk.vercel.app/docs/api#createmutation
|
|
38
|
+
*/
|
|
36
39
|
export declare const createMutation: <TVar, TResponse = any, TError = unknown>(mutationFn: (variables: TVar, state: MutationState<TVar, TResponse, TError>) => Promise<TResponse>, options?: CreateMutationOptions<TVar, TResponse, TError>) => UseMutation<TVar, TResponse, TError>;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { noop } from '../utils';
|
|
2
2
|
import { createStore } from './create-store';
|
|
3
|
+
/**
|
|
4
|
+
* @see https://floppy-disk.vercel.app/docs/api#createmutation
|
|
5
|
+
*/
|
|
3
6
|
export const createMutation = (mutationFn, options = {}) => {
|
|
4
7
|
const { onMutate = noop, onSuccess = noop, onError = noop, onSettled = noop, ...createStoreOptions } = options;
|
|
5
8
|
const useMutation = createStore(({ set, get }) => ({
|
|
@@ -197,7 +197,9 @@ export type CreateQueryOptions<TKey extends StoreKey = StoreKey, TResponse = any
|
|
|
197
197
|
*
|
|
198
198
|
* Disabled by default.
|
|
199
199
|
*
|
|
200
|
-
* If
|
|
200
|
+
* If last data fetching is failed, the polling interval will be disabled, and it will use `retry` mechanism instead.
|
|
201
|
+
*
|
|
202
|
+
* @see https://floppy-disk.vercel.app/docs/query/polling
|
|
201
203
|
*/
|
|
202
204
|
refetchInterval?: number | false | ((state: QueryState<TKey, TResponse, TData, TError>) => number | false);
|
|
203
205
|
};
|
|
@@ -257,4 +259,7 @@ export type UseQuery<TKey extends StoreKey = StoreKey, TResponse = any, TData =
|
|
|
257
259
|
error?: FunctionComponent<TKey>;
|
|
258
260
|
}) => JSX.Element;
|
|
259
261
|
};
|
|
262
|
+
/**
|
|
263
|
+
* @see https://floppy-disk.vercel.app/docs/api#createquery
|
|
264
|
+
*/
|
|
260
265
|
export declare const createQuery: <TKey extends StoreKey = StoreKey, TResponse = any, TData = TResponse, TError = unknown>(queryFn: (key: TKey, state: QueryState<TKey, TResponse, TData, TError>) => Promise<TResponse>, options?: CreateQueryOptions<TKey, TResponse, TData, TError>) => UseQuery<TKey, TResponse, TData, TError>;
|
|
@@ -31,6 +31,9 @@ const useQueryDefaultDeps = (state) => [
|
|
|
31
31
|
state.isWaitingNextPage,
|
|
32
32
|
state.hasNextPage,
|
|
33
33
|
];
|
|
34
|
+
/**
|
|
35
|
+
* @see https://floppy-disk.vercel.app/docs/api#createquery
|
|
36
|
+
*/
|
|
34
37
|
export const createQuery = (queryFn, options = {}) => {
|
|
35
38
|
const defaultFetchOnWindowFocus = options.fetchOnMount ?? true;
|
|
36
39
|
const { onFirstSubscribe = noop, onSubscribe = noop, onLastUnsubscribe = noop, onBeforeChangeKey = noop, defaultDeps = useQueryDefaultDeps, select = identityFn, staleTime = 3000, // 3 seconds
|
|
@@ -23,6 +23,9 @@ export type UseStore<T extends StoreData> = {
|
|
|
23
23
|
setDefaultValues: (values: SetStoreData<T>) => void;
|
|
24
24
|
Watch: (props: WatchProps<T>) => any;
|
|
25
25
|
};
|
|
26
|
+
/**
|
|
27
|
+
* @see https://floppy-disk.vercel.app/docs/api#createstore
|
|
28
|
+
*/
|
|
26
29
|
export declare const createStore: <T extends StoreData>(initializer: StoreInitializer<T>, options?: InitStoreOptions<T> & {
|
|
27
30
|
defaultDeps?: SelectDeps<T>;
|
|
28
31
|
}) => UseStore<T>;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { useEffect, useState } from 'react';
|
|
2
2
|
import { initStore, } from '../vanilla';
|
|
3
|
+
/**
|
|
4
|
+
* @see https://floppy-disk.vercel.app/docs/api#createstore
|
|
5
|
+
*/
|
|
3
6
|
export const createStore = (initializer, options = {}) => {
|
|
4
7
|
const { get, set, subscribe, getSubscribers } = initStore(initializer, options);
|
|
5
8
|
const { defaultDeps } = options;
|
|
@@ -46,5 +46,8 @@ export type CreateStoresOptions<TKey extends StoreKey = StoreKey, T extends Stor
|
|
|
46
46
|
defaultDeps?: SelectDeps<T>;
|
|
47
47
|
hashKeyFn?: (obj: TKey) => string;
|
|
48
48
|
};
|
|
49
|
+
/**
|
|
50
|
+
* @see https://floppy-disk.vercel.app/docs/api#createstores
|
|
51
|
+
*/
|
|
49
52
|
export declare const createStores: <TKey extends StoreKey = StoreKey, T extends StoreData = StoreData>(initializer: StoresInitializer<TKey, T>, options?: CreateStoresOptions<TKey, T>) => UseStores<TKey, T>;
|
|
50
53
|
export {};
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { useEffect, useMemo, useRef, useState } from 'react';
|
|
2
2
|
import { hashStoreKey, noop } from '../utils';
|
|
3
3
|
import { initStore, } from '../vanilla';
|
|
4
|
+
/**
|
|
5
|
+
* @see https://floppy-disk.vercel.app/docs/api#createstores
|
|
6
|
+
*/
|
|
4
7
|
export const createStores = (initializer, options = {}) => {
|
|
5
8
|
const { onBeforeChangeKey = noop, onStoreInitialized = noop, defaultDeps, hashKeyFn = hashStoreKey, } = options;
|
|
6
9
|
const stores = new Map();
|
|
@@ -33,4 +33,7 @@ export type CreateMutationOptions<TVar, TResponse = any, TError = unknown> = Ini
|
|
|
33
33
|
onError?: (error: TError, variables: TVar, stateBeforeMutate: MutationState<TVar, TResponse, TError>) => void;
|
|
34
34
|
onSettled?: (variables: TVar, stateBeforeMutate: MutationState<TVar, TResponse, TError>) => void;
|
|
35
35
|
};
|
|
36
|
+
/**
|
|
37
|
+
* @see https://floppy-disk.vercel.app/docs/api#createmutation
|
|
38
|
+
*/
|
|
36
39
|
export declare const createMutation: <TVar, TResponse = any, TError = unknown>(mutationFn: (variables: TVar, state: MutationState<TVar, TResponse, TError>) => Promise<TResponse>, options?: CreateMutationOptions<TVar, TResponse, TError>) => UseMutation<TVar, TResponse, TError>;
|
|
@@ -3,6 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.createMutation = void 0;
|
|
4
4
|
const utils_1 = require("../utils");
|
|
5
5
|
const create_store_1 = require("./create-store");
|
|
6
|
+
/**
|
|
7
|
+
* @see https://floppy-disk.vercel.app/docs/api#createmutation
|
|
8
|
+
*/
|
|
6
9
|
const createMutation = (mutationFn, options = {}) => {
|
|
7
10
|
const { onMutate = utils_1.noop, onSuccess = utils_1.noop, onError = utils_1.noop, onSettled = utils_1.noop, ...createStoreOptions } = options;
|
|
8
11
|
const useMutation = (0, create_store_1.createStore)(({ set, get }) => ({
|
|
@@ -198,7 +198,9 @@ export type CreateQueryOptions<TKey extends StoreKey = StoreKey, TResponse = any
|
|
|
198
198
|
*
|
|
199
199
|
* Disabled by default.
|
|
200
200
|
*
|
|
201
|
-
* If
|
|
201
|
+
* If last data fetching is failed, the polling interval will be disabled, and it will use `retry` mechanism instead.
|
|
202
|
+
*
|
|
203
|
+
* @see https://floppy-disk.vercel.app/docs/query/polling
|
|
202
204
|
*/
|
|
203
205
|
refetchInterval?: number | false | ((state: QueryState<TKey, TResponse, TData, TError>) => number | false);
|
|
204
206
|
};
|
|
@@ -258,4 +260,7 @@ export type UseQuery<TKey extends StoreKey = StoreKey, TResponse = any, TData =
|
|
|
258
260
|
error?: FunctionComponent<TKey>;
|
|
259
261
|
}) => JSX.Element;
|
|
260
262
|
};
|
|
263
|
+
/**
|
|
264
|
+
* @see https://floppy-disk.vercel.app/docs/api#createquery
|
|
265
|
+
*/
|
|
261
266
|
export declare const createQuery: <TKey extends StoreKey = StoreKey, TResponse = any, TData = TResponse, TError = unknown>(queryFn: (key: TKey, state: QueryState<TKey, TResponse, TData, TError>) => Promise<TResponse>, options?: CreateQueryOptions<TKey, TResponse, TData, TError>) => UseQuery<TKey, TResponse, TData, TError>;
|
|
@@ -35,6 +35,9 @@ const useQueryDefaultDeps = (state) => [
|
|
|
35
35
|
state.isWaitingNextPage,
|
|
36
36
|
state.hasNextPage,
|
|
37
37
|
];
|
|
38
|
+
/**
|
|
39
|
+
* @see https://floppy-disk.vercel.app/docs/api#createquery
|
|
40
|
+
*/
|
|
38
41
|
const createQuery = (queryFn, options = {}) => {
|
|
39
42
|
const defaultFetchOnWindowFocus = options.fetchOnMount ?? true;
|
|
40
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 = 3000, // 3 seconds
|
|
@@ -23,6 +23,9 @@ export type UseStore<T extends StoreData> = {
|
|
|
23
23
|
setDefaultValues: (values: SetStoreData<T>) => void;
|
|
24
24
|
Watch: (props: WatchProps<T>) => any;
|
|
25
25
|
};
|
|
26
|
+
/**
|
|
27
|
+
* @see https://floppy-disk.vercel.app/docs/api#createstore
|
|
28
|
+
*/
|
|
26
29
|
export declare const createStore: <T extends StoreData>(initializer: StoreInitializer<T>, options?: InitStoreOptions<T> & {
|
|
27
30
|
defaultDeps?: SelectDeps<T>;
|
|
28
31
|
}) => UseStore<T>;
|
|
@@ -3,6 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.createStore = void 0;
|
|
4
4
|
const hooks_1 = require("preact/hooks");
|
|
5
5
|
const vanilla_1 = require("../vanilla");
|
|
6
|
+
/**
|
|
7
|
+
* @see https://floppy-disk.vercel.app/docs/api#createstore
|
|
8
|
+
*/
|
|
6
9
|
const createStore = (initializer, options = {}) => {
|
|
7
10
|
const { get, set, subscribe, getSubscribers } = (0, vanilla_1.initStore)(initializer, options);
|
|
8
11
|
const { defaultDeps } = options;
|
|
@@ -46,5 +46,8 @@ export type CreateStoresOptions<TKey extends StoreKey = StoreKey, T extends Stor
|
|
|
46
46
|
defaultDeps?: SelectDeps<T>;
|
|
47
47
|
hashKeyFn?: (obj: TKey) => string;
|
|
48
48
|
};
|
|
49
|
+
/**
|
|
50
|
+
* @see https://floppy-disk.vercel.app/docs/api#createstores
|
|
51
|
+
*/
|
|
49
52
|
export declare const createStores: <TKey extends StoreKey = StoreKey, T extends StoreData = StoreData>(initializer: StoresInitializer<TKey, T>, options?: CreateStoresOptions<TKey, T>) => UseStores<TKey, T>;
|
|
50
53
|
export {};
|
|
@@ -4,6 +4,9 @@ exports.createStores = void 0;
|
|
|
4
4
|
const hooks_1 = require("preact/hooks");
|
|
5
5
|
const utils_1 = require("../utils");
|
|
6
6
|
const vanilla_1 = require("../vanilla");
|
|
7
|
+
/**
|
|
8
|
+
* @see https://floppy-disk.vercel.app/docs/api#createstores
|
|
9
|
+
*/
|
|
7
10
|
const createStores = (initializer, options = {}) => {
|
|
8
11
|
const { onBeforeChangeKey = utils_1.noop, onStoreInitialized = utils_1.noop, defaultDeps, hashKeyFn = utils_1.hashStoreKey, } = options;
|
|
9
12
|
const stores = new Map();
|
|
@@ -33,4 +33,7 @@ export type CreateMutationOptions<TVar, TResponse = any, TError = unknown> = Ini
|
|
|
33
33
|
onError?: (error: TError, variables: TVar, stateBeforeMutate: MutationState<TVar, TResponse, TError>) => void;
|
|
34
34
|
onSettled?: (variables: TVar, stateBeforeMutate: MutationState<TVar, TResponse, TError>) => void;
|
|
35
35
|
};
|
|
36
|
+
/**
|
|
37
|
+
* @see https://floppy-disk.vercel.app/docs/api#createmutation
|
|
38
|
+
*/
|
|
36
39
|
export declare const createMutation: <TVar, TResponse = any, TError = unknown>(mutationFn: (variables: TVar, state: MutationState<TVar, TResponse, TError>) => Promise<TResponse>, options?: CreateMutationOptions<TVar, TResponse, TError>) => UseMutation<TVar, TResponse, TError>;
|
|
@@ -3,6 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.createMutation = void 0;
|
|
4
4
|
const utils_1 = require("../utils");
|
|
5
5
|
const create_store_1 = require("./create-store");
|
|
6
|
+
/**
|
|
7
|
+
* @see https://floppy-disk.vercel.app/docs/api#createmutation
|
|
8
|
+
*/
|
|
6
9
|
const createMutation = (mutationFn, options = {}) => {
|
|
7
10
|
const { onMutate = utils_1.noop, onSuccess = utils_1.noop, onError = utils_1.noop, onSettled = utils_1.noop, ...createStoreOptions } = options;
|
|
8
11
|
const useMutation = (0, create_store_1.createStore)(({ set, get }) => ({
|
|
@@ -197,7 +197,9 @@ export type CreateQueryOptions<TKey extends StoreKey = StoreKey, TResponse = any
|
|
|
197
197
|
*
|
|
198
198
|
* Disabled by default.
|
|
199
199
|
*
|
|
200
|
-
* If
|
|
200
|
+
* If last data fetching is failed, the polling interval will be disabled, and it will use `retry` mechanism instead.
|
|
201
|
+
*
|
|
202
|
+
* @see https://floppy-disk.vercel.app/docs/query/polling
|
|
201
203
|
*/
|
|
202
204
|
refetchInterval?: number | false | ((state: QueryState<TKey, TResponse, TData, TError>) => number | false);
|
|
203
205
|
};
|
|
@@ -257,4 +259,7 @@ export type UseQuery<TKey extends StoreKey = StoreKey, TResponse = any, TData =
|
|
|
257
259
|
error?: FunctionComponent<TKey>;
|
|
258
260
|
}) => JSX.Element;
|
|
259
261
|
};
|
|
262
|
+
/**
|
|
263
|
+
* @see https://floppy-disk.vercel.app/docs/api#createquery
|
|
264
|
+
*/
|
|
260
265
|
export declare const createQuery: <TKey extends StoreKey = StoreKey, TResponse = any, TData = TResponse, TError = unknown>(queryFn: (key: TKey, state: QueryState<TKey, TResponse, TData, TError>) => Promise<TResponse>, options?: CreateQueryOptions<TKey, TResponse, TData, TError>) => UseQuery<TKey, TResponse, TData, TError>;
|
|
@@ -34,6 +34,9 @@ const useQueryDefaultDeps = (state) => [
|
|
|
34
34
|
state.isWaitingNextPage,
|
|
35
35
|
state.hasNextPage,
|
|
36
36
|
];
|
|
37
|
+
/**
|
|
38
|
+
* @see https://floppy-disk.vercel.app/docs/api#createquery
|
|
39
|
+
*/
|
|
37
40
|
const createQuery = (queryFn, options = {}) => {
|
|
38
41
|
const defaultFetchOnWindowFocus = options.fetchOnMount ?? true;
|
|
39
42
|
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
|
|
@@ -23,6 +23,9 @@ export type UseStore<T extends StoreData> = {
|
|
|
23
23
|
setDefaultValues: (values: SetStoreData<T>) => void;
|
|
24
24
|
Watch: (props: WatchProps<T>) => any;
|
|
25
25
|
};
|
|
26
|
+
/**
|
|
27
|
+
* @see https://floppy-disk.vercel.app/docs/api#createstore
|
|
28
|
+
*/
|
|
26
29
|
export declare const createStore: <T extends StoreData>(initializer: StoreInitializer<T>, options?: InitStoreOptions<T> & {
|
|
27
30
|
defaultDeps?: SelectDeps<T>;
|
|
28
31
|
}) => UseStore<T>;
|
|
@@ -3,6 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.createStore = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
const vanilla_1 = require("../vanilla");
|
|
6
|
+
/**
|
|
7
|
+
* @see https://floppy-disk.vercel.app/docs/api#createstore
|
|
8
|
+
*/
|
|
6
9
|
const createStore = (initializer, options = {}) => {
|
|
7
10
|
const { get, set, subscribe, getSubscribers } = (0, vanilla_1.initStore)(initializer, options);
|
|
8
11
|
const { defaultDeps } = options;
|
|
@@ -46,5 +46,8 @@ export type CreateStoresOptions<TKey extends StoreKey = StoreKey, T extends Stor
|
|
|
46
46
|
defaultDeps?: SelectDeps<T>;
|
|
47
47
|
hashKeyFn?: (obj: TKey) => string;
|
|
48
48
|
};
|
|
49
|
+
/**
|
|
50
|
+
* @see https://floppy-disk.vercel.app/docs/api#createstores
|
|
51
|
+
*/
|
|
49
52
|
export declare const createStores: <TKey extends StoreKey = StoreKey, T extends StoreData = StoreData>(initializer: StoresInitializer<TKey, T>, options?: CreateStoresOptions<TKey, T>) => UseStores<TKey, T>;
|
|
50
53
|
export {};
|
|
@@ -4,6 +4,9 @@ exports.createStores = void 0;
|
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
const utils_1 = require("../utils");
|
|
6
6
|
const vanilla_1 = require("../vanilla");
|
|
7
|
+
/**
|
|
8
|
+
* @see https://floppy-disk.vercel.app/docs/api#createstores
|
|
9
|
+
*/
|
|
7
10
|
const createStores = (initializer, options = {}) => {
|
|
8
11
|
const { onBeforeChangeKey = utils_1.noop, onStoreInitialized = utils_1.noop, defaultDeps, hashKeyFn = utils_1.hashStoreKey, } = options;
|
|
9
12
|
const stores = new Map();
|