MCPcopy Create free account
hub / github.com/TanStack/query / getResult

Function getResult

packages/solid-query/src/useMutationState.ts:40–56  ·  view source on GitHub ↗

* Collects the mutations in the cache that match `options.filters`, mapped with `options.select` * (or to their state, by default). * @param mutationCache - The mutation cache to read. * @param options - The `filters` to match and the `select` function to map each mutation with. * @returns The s

(
  mutationCache: MutationCache,
  options: MutationStateOptions<TResult, TMutation>,
)

Source from the content-addressed store, hash-verified

38 * @returns The selected value of every matching mutation.
39 */
40function getResult<
41 TResult = MutationState,
42 TMutation extends Mutation<any, any, any, any> =
43 MutationTypeFromResult<TResult>,
44>(
45 mutationCache: MutationCache,
46 options: MutationStateOptions<TResult, TMutation>,
47): Array<TResult> {
48 return mutationCache
49 .findAll(options.filters)
50 .map(
51 (mutation): TResult =>
52 (options.select
53 ? options.select(mutation as TMutation)
54 : mutation.state) as TResult,
55 )
56}
57
58/**
59 * `useMutationState` is a primitive that gives you access to all mutations in the `MutationCache`. You can pass

Callers 1

useMutationStateFunction · 0.70

Calls 1

findAllMethod · 0.45

Tested by

no test coverage detected