@mittwald/react-ghostmaker 1.5.0 → 1.5.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.
@@ -6,6 +6,7 @@ import { queries } from "./queries.js";
6
6
  import { ghostFnContext } from "./context.js";
7
7
  import { invalidateGhosts } from "./invalidate.js";
8
8
  import { hashObject } from "./hash.js";
9
+ import { resetGhosts } from "./reset.js";
9
10
  export const useGhostChain = (target, chain, options) => {
10
11
  const queryClient = useQueryClient();
11
12
  const context = {
@@ -13,9 +14,11 @@ export const useGhostChain = (target, chain, options) => {
13
14
  };
14
15
  const value = chain.reduce((currentTarget, item) => useGhostChainItem(currentTarget, item, options, context), target);
15
16
  const invalidate = () => invalidateGhosts(queryClient, queries.ghostChain(target, chain));
17
+ const reset = () => resetGhosts(queryClient, queries.ghostChain(target, chain));
16
18
  return {
17
19
  value,
18
20
  invalidate,
21
+ reset,
19
22
  };
20
23
  };
21
24
  const useGhostChainItem = (target, item, options = {}, context) => {
@@ -31,12 +31,14 @@ export type GhostChain = GhostChainItem[];
31
31
  export type GhostChainTargetType = UnknownRecord | Class<unknown> | null | undefined;
32
32
  export type QueryKey = readonly unknown[];
33
33
  export type InvalidateGhostFn = () => Promise<void>;
34
+ export type ResetGhostFn = () => Promise<void>;
34
35
  export interface GhostChainContext {
35
36
  queryKey: QueryKey;
36
37
  }
37
38
  export interface UseGhostReturn<T> {
38
39
  value: T;
39
40
  invalidate: InvalidateGhostFn;
41
+ reset: ResetGhostFn;
40
42
  }
41
43
  export declare function isReactGhost<T>(something: unknown): something is ReactGhost<T>;
42
44
  export type ModelIdentifier = (model: unknown) => string | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mittwald/react-ghostmaker",
3
- "version": "1.5.0",
3
+ "version": "1.5.1",
4
4
  "author": "Mittwald CM Service GmbH & Co. KG <opensource@mittwald.de>",
5
5
  "contributors": [
6
6
  "Marco Falkenberg <m.falkenberg@mittwald.de>"