floppy-disk 2.0.0 → 2.0.1-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-mutation.d.ts +10 -6
- package/esm/preact/create-mutation.js +2 -2
- package/esm/preact/create-query.js +1 -0
- package/esm/react/create-mutation.d.ts +10 -6
- package/esm/react/create-mutation.js +2 -2
- package/esm/react/create-query.js +1 -0
- package/lib/preact/create-mutation.d.ts +10 -6
- package/lib/preact/create-mutation.js +2 -2
- package/lib/preact/create-query.js +1 -0
- package/lib/react/create-mutation.d.ts +10 -6
- package/lib/react/create-mutation.js +2 -2
- package/lib/react/create-query.js +1 -0
- package/package.json +1 -1
|
@@ -13,16 +13,20 @@ export type MutationState<TVar, TResponse = any, TError = unknown> = {
|
|
|
13
13
|
/**
|
|
14
14
|
* Mutate function is a promise that will always resolve.
|
|
15
15
|
*/
|
|
16
|
-
mutate: (
|
|
16
|
+
mutate: TVar extends undefined ? () => Promise<{
|
|
17
|
+
response?: TResponse;
|
|
18
|
+
error?: TError;
|
|
19
|
+
variables?: TVar;
|
|
20
|
+
}> : (variables: TVar) => Promise<{
|
|
17
21
|
response?: TResponse;
|
|
18
22
|
error?: TError;
|
|
19
23
|
variables?: TVar;
|
|
20
24
|
}>;
|
|
21
25
|
};
|
|
22
26
|
export type CreateMutationOptions<TVar, TResponse = any, TError = unknown> = InitStoreOptions<MutationState<TVar, TResponse, TError>> & {
|
|
23
|
-
onMutate?: (variables: TVar
|
|
24
|
-
onSuccess?: (response: TResponse, variables: TVar
|
|
25
|
-
onError?: (error: TError, variables: TVar
|
|
26
|
-
onSettled?: (variables: TVar
|
|
27
|
+
onMutate?: (variables: TVar, stateBeforeMutate: MutationState<TVar, TResponse, TError>) => void;
|
|
28
|
+
onSuccess?: (response: TResponse, variables: TVar, stateBeforeMutate: MutationState<TVar, TResponse, TError>) => void;
|
|
29
|
+
onError?: (error: TError, variables: TVar, stateBeforeMutate: MutationState<TVar, TResponse, TError>) => void;
|
|
30
|
+
onSettled?: (variables: TVar, stateBeforeMutate: MutationState<TVar, TResponse, TError>) => void;
|
|
27
31
|
};
|
|
28
|
-
export declare const createMutation: <TVar, TResponse = any, TError = unknown>(mutationFn: (variables: TVar
|
|
32
|
+
export declare const createMutation: <TVar, TResponse = any, TError = unknown>(mutationFn: (variables: TVar, state: MutationState<TVar, TResponse, TError>) => Promise<TResponse>, options?: CreateMutationOptions<TVar, TResponse, TError>) => import("./create-store").UseStore<MutationState<TVar, TResponse, TError>>;
|
|
@@ -10,7 +10,7 @@ export const createMutation = (mutationFn, options = {}) => {
|
|
|
10
10
|
responseUpdatedAt: null,
|
|
11
11
|
error: null,
|
|
12
12
|
errorUpdatedAt: null,
|
|
13
|
-
mutate: (variables) => {
|
|
13
|
+
mutate: ((variables) => {
|
|
14
14
|
set({ isWaiting: true });
|
|
15
15
|
const stateBeforeMutate = get();
|
|
16
16
|
onMutate(variables, stateBeforeMutate);
|
|
@@ -44,7 +44,7 @@ export const createMutation = (mutationFn, options = {}) => {
|
|
|
44
44
|
onSettled(variables, stateBeforeMutate);
|
|
45
45
|
});
|
|
46
46
|
});
|
|
47
|
-
},
|
|
47
|
+
}),
|
|
48
48
|
}), createStoreOptions);
|
|
49
49
|
return useMutation;
|
|
50
50
|
};
|
|
@@ -13,16 +13,20 @@ export type MutationState<TVar, TResponse = any, TError = unknown> = {
|
|
|
13
13
|
/**
|
|
14
14
|
* Mutate function is a promise that will always resolve.
|
|
15
15
|
*/
|
|
16
|
-
mutate: (
|
|
16
|
+
mutate: TVar extends undefined ? () => Promise<{
|
|
17
|
+
response?: TResponse;
|
|
18
|
+
error?: TError;
|
|
19
|
+
variables?: TVar;
|
|
20
|
+
}> : (variables: TVar) => Promise<{
|
|
17
21
|
response?: TResponse;
|
|
18
22
|
error?: TError;
|
|
19
23
|
variables?: TVar;
|
|
20
24
|
}>;
|
|
21
25
|
};
|
|
22
26
|
export type CreateMutationOptions<TVar, TResponse = any, TError = unknown> = InitStoreOptions<MutationState<TVar, TResponse, TError>> & {
|
|
23
|
-
onMutate?: (variables: TVar
|
|
24
|
-
onSuccess?: (response: TResponse, variables: TVar
|
|
25
|
-
onError?: (error: TError, variables: TVar
|
|
26
|
-
onSettled?: (variables: TVar
|
|
27
|
+
onMutate?: (variables: TVar, stateBeforeMutate: MutationState<TVar, TResponse, TError>) => void;
|
|
28
|
+
onSuccess?: (response: TResponse, variables: TVar, stateBeforeMutate: MutationState<TVar, TResponse, TError>) => void;
|
|
29
|
+
onError?: (error: TError, variables: TVar, stateBeforeMutate: MutationState<TVar, TResponse, TError>) => void;
|
|
30
|
+
onSettled?: (variables: TVar, stateBeforeMutate: MutationState<TVar, TResponse, TError>) => void;
|
|
27
31
|
};
|
|
28
|
-
export declare const createMutation: <TVar, TResponse = any, TError = unknown>(mutationFn: (variables: TVar
|
|
32
|
+
export declare const createMutation: <TVar, TResponse = any, TError = unknown>(mutationFn: (variables: TVar, state: MutationState<TVar, TResponse, TError>) => Promise<TResponse>, options?: CreateMutationOptions<TVar, TResponse, TError>) => import("./create-store").UseStore<MutationState<TVar, TResponse, TError>>;
|
|
@@ -10,7 +10,7 @@ export const createMutation = (mutationFn, options = {}) => {
|
|
|
10
10
|
responseUpdatedAt: null,
|
|
11
11
|
error: null,
|
|
12
12
|
errorUpdatedAt: null,
|
|
13
|
-
mutate: (variables) => {
|
|
13
|
+
mutate: ((variables) => {
|
|
14
14
|
set({ isWaiting: true });
|
|
15
15
|
const stateBeforeMutate = get();
|
|
16
16
|
onMutate(variables, stateBeforeMutate);
|
|
@@ -44,7 +44,7 @@ export const createMutation = (mutationFn, options = {}) => {
|
|
|
44
44
|
onSettled(variables, stateBeforeMutate);
|
|
45
45
|
});
|
|
46
46
|
});
|
|
47
|
-
},
|
|
47
|
+
}),
|
|
48
48
|
}), createStoreOptions);
|
|
49
49
|
return useMutation;
|
|
50
50
|
};
|
|
@@ -13,16 +13,20 @@ export type MutationState<TVar, TResponse = any, TError = unknown> = {
|
|
|
13
13
|
/**
|
|
14
14
|
* Mutate function is a promise that will always resolve.
|
|
15
15
|
*/
|
|
16
|
-
mutate: (
|
|
16
|
+
mutate: TVar extends undefined ? () => Promise<{
|
|
17
|
+
response?: TResponse;
|
|
18
|
+
error?: TError;
|
|
19
|
+
variables?: TVar;
|
|
20
|
+
}> : (variables: TVar) => Promise<{
|
|
17
21
|
response?: TResponse;
|
|
18
22
|
error?: TError;
|
|
19
23
|
variables?: TVar;
|
|
20
24
|
}>;
|
|
21
25
|
};
|
|
22
26
|
export type CreateMutationOptions<TVar, TResponse = any, TError = unknown> = InitStoreOptions<MutationState<TVar, TResponse, TError>> & {
|
|
23
|
-
onMutate?: (variables: TVar
|
|
24
|
-
onSuccess?: (response: TResponse, variables: TVar
|
|
25
|
-
onError?: (error: TError, variables: TVar
|
|
26
|
-
onSettled?: (variables: TVar
|
|
27
|
+
onMutate?: (variables: TVar, stateBeforeMutate: MutationState<TVar, TResponse, TError>) => void;
|
|
28
|
+
onSuccess?: (response: TResponse, variables: TVar, stateBeforeMutate: MutationState<TVar, TResponse, TError>) => void;
|
|
29
|
+
onError?: (error: TError, variables: TVar, stateBeforeMutate: MutationState<TVar, TResponse, TError>) => void;
|
|
30
|
+
onSettled?: (variables: TVar, stateBeforeMutate: MutationState<TVar, TResponse, TError>) => void;
|
|
27
31
|
};
|
|
28
|
-
export declare const createMutation: <TVar, TResponse = any, TError = unknown>(mutationFn: (variables: TVar
|
|
32
|
+
export declare const createMutation: <TVar, TResponse = any, TError = unknown>(mutationFn: (variables: TVar, state: MutationState<TVar, TResponse, TError>) => Promise<TResponse>, options?: CreateMutationOptions<TVar, TResponse, TError>) => import("./create-store").UseStore<MutationState<TVar, TResponse, TError>>;
|
|
@@ -13,7 +13,7 @@ const createMutation = (mutationFn, options = {}) => {
|
|
|
13
13
|
responseUpdatedAt: null,
|
|
14
14
|
error: null,
|
|
15
15
|
errorUpdatedAt: null,
|
|
16
|
-
mutate: (variables) => {
|
|
16
|
+
mutate: ((variables) => {
|
|
17
17
|
set({ isWaiting: true });
|
|
18
18
|
const stateBeforeMutate = get();
|
|
19
19
|
onMutate(variables, stateBeforeMutate);
|
|
@@ -47,7 +47,7 @@ const createMutation = (mutationFn, options = {}) => {
|
|
|
47
47
|
onSettled(variables, stateBeforeMutate);
|
|
48
48
|
});
|
|
49
49
|
});
|
|
50
|
-
},
|
|
50
|
+
}),
|
|
51
51
|
}), createStoreOptions);
|
|
52
52
|
return useMutation;
|
|
53
53
|
};
|
|
@@ -13,16 +13,20 @@ export type MutationState<TVar, TResponse = any, TError = unknown> = {
|
|
|
13
13
|
/**
|
|
14
14
|
* Mutate function is a promise that will always resolve.
|
|
15
15
|
*/
|
|
16
|
-
mutate: (
|
|
16
|
+
mutate: TVar extends undefined ? () => Promise<{
|
|
17
|
+
response?: TResponse;
|
|
18
|
+
error?: TError;
|
|
19
|
+
variables?: TVar;
|
|
20
|
+
}> : (variables: TVar) => Promise<{
|
|
17
21
|
response?: TResponse;
|
|
18
22
|
error?: TError;
|
|
19
23
|
variables?: TVar;
|
|
20
24
|
}>;
|
|
21
25
|
};
|
|
22
26
|
export type CreateMutationOptions<TVar, TResponse = any, TError = unknown> = InitStoreOptions<MutationState<TVar, TResponse, TError>> & {
|
|
23
|
-
onMutate?: (variables: TVar
|
|
24
|
-
onSuccess?: (response: TResponse, variables: TVar
|
|
25
|
-
onError?: (error: TError, variables: TVar
|
|
26
|
-
onSettled?: (variables: TVar
|
|
27
|
+
onMutate?: (variables: TVar, stateBeforeMutate: MutationState<TVar, TResponse, TError>) => void;
|
|
28
|
+
onSuccess?: (response: TResponse, variables: TVar, stateBeforeMutate: MutationState<TVar, TResponse, TError>) => void;
|
|
29
|
+
onError?: (error: TError, variables: TVar, stateBeforeMutate: MutationState<TVar, TResponse, TError>) => void;
|
|
30
|
+
onSettled?: (variables: TVar, stateBeforeMutate: MutationState<TVar, TResponse, TError>) => void;
|
|
27
31
|
};
|
|
28
|
-
export declare const createMutation: <TVar, TResponse = any, TError = unknown>(mutationFn: (variables: TVar
|
|
32
|
+
export declare const createMutation: <TVar, TResponse = any, TError = unknown>(mutationFn: (variables: TVar, state: MutationState<TVar, TResponse, TError>) => Promise<TResponse>, options?: CreateMutationOptions<TVar, TResponse, TError>) => import("./create-store").UseStore<MutationState<TVar, TResponse, TError>>;
|
|
@@ -13,7 +13,7 @@ const createMutation = (mutationFn, options = {}) => {
|
|
|
13
13
|
responseUpdatedAt: null,
|
|
14
14
|
error: null,
|
|
15
15
|
errorUpdatedAt: null,
|
|
16
|
-
mutate: (variables) => {
|
|
16
|
+
mutate: ((variables) => {
|
|
17
17
|
set({ isWaiting: true });
|
|
18
18
|
const stateBeforeMutate = get();
|
|
19
19
|
onMutate(variables, stateBeforeMutate);
|
|
@@ -47,7 +47,7 @@ const createMutation = (mutationFn, options = {}) => {
|
|
|
47
47
|
onSettled(variables, stateBeforeMutate);
|
|
48
48
|
});
|
|
49
49
|
});
|
|
50
|
-
},
|
|
50
|
+
}),
|
|
51
51
|
}), createStoreOptions);
|
|
52
52
|
return useMutation;
|
|
53
53
|
};
|