Skip to content

Commit 306b672

Browse files
committed
docs: update docs for queries and mutations (lazy option)
1 parent bee7713 commit 306b672

File tree

4 files changed

+245
-145
lines changed

4 files changed

+245
-145
lines changed

docs/api/InfiniteQuery.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ Class wrapper for [@tanstack-query/core infinite queries](https://tanstack.com/q
44

55
[_See docs for Query_](/api/Query)
66

7+
**All documentation about properties and methods of infinite query can be found in the original documentation [here](https://tanstack.com/query/latest/docs/framework/react/reference/useInfiniteQuery)**
8+
79
[Reference to source code](/src/infinite-query.ts)
810

911
## Usage

docs/api/Mutation.md

Lines changed: 43 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
# Mutation
1+
# Mutation
22

3-
Class wrapper for [@tanstack-query/core mutations](https://tanstack.com/query/latest/docs/framework/react/guides/mutations) with **MobX** reactivity
3+
Class wrapper for [@tanstack-query/core mutations](https://tanstack.com/query/latest/docs/framework/react/guides/mutations) with **MobX** reactivity
44

5-
[Reference to source code](/src/mutation.ts)
5+
**All documentation about properties and methods of mutation can be found in the original documentation [here](https://tanstack.com/query/latest/docs/framework/react/reference/useMutation)**
66

7-
## Usage
7+
[Reference to source code](/src/mutation.ts)
8+
9+
## Usage
810

911
Create an instance of `Mutation` with [`mutationFn`](https://tanstack.com/query/latest/docs/framework/react/guides/mutations) parameter
1012

@@ -36,12 +38,13 @@ const petCreateMutation = new Mutation({
3638
const result = await petCreateMutation.mutate('Fluffy');
3739
console.info(result.data, result.isPending, result.isError);
3840

39-
```
41+
```
42+
43+
## Built-in Features
4044

41-
## Built-in Features
45+
### `abortSignal` option
4246

43-
### `abortSignal` option
44-
This field is necessary to kill all reactions and subscriptions that are created during the creation of an instance of the `Mutation` class
47+
This field is necessary to kill all reactions and subscriptions that are created during the creation of an instance of the `Mutation` class
4548

4649
```ts
4750
const abortController = new AbortController();
@@ -61,27 +64,46 @@ abortController.abort();
6164

6265
This is alternative for `destroy` method
6366

64-
### `destroy()` method
65-
This method is necessary to kill all reactions and subscriptions that are created during the creation of an instance of the `Mutation` class
67+
### `lazy` option
68+
69+
This option enables "lazy" mode of the mutation. That means that all subscriptions and reaction will be created only when you request result for this mutation.
70+
71+
Example:
72+
73+
```ts
74+
const mutation = createMutation(queryClient, () => ({
75+
lazy: true,
76+
mutationFn: async () => {
77+
// api call
78+
},
79+
}));
80+
81+
// happens nothing
82+
// no reactions and subscriptions will be created
83+
```
84+
85+
### `destroy()` method
86+
87+
This method is necessary to kill all reactions and subscriptions that are created during the creation of an instance of the `Mutation` class
6688

67-
This is alternative for `abortSignal` option
89+
This is alternative for `abortSignal` option
6890

69-
### method `mutate(variables, options?)`
70-
Runs the mutation. (Works the as `mutate` function in [`useMutation` hook](https://tanstack.com/query/latest/docs/framework/react/reference/useMutation))
91+
### method `mutate(variables, options?)`
7192

72-
### hook `onDone()`
73-
Subscribe when mutation has been successfully finished
93+
Runs the mutation. (Works the as `mutate` function in [`useMutation` hook](https://tanstack.com/query/latest/docs/framework/react/reference/useMutation))
7494

75-
### hook `onError()`
76-
Subscribe when mutation has been finished with failure
95+
### hook `onDone()`
7796

78-
### method `reset()`
79-
Reset current mutation
97+
Subscribe when mutation has been successfully finished
8098

81-
### property `result` <Badge type="info" text="observable.deep" />
82-
Mutation result (The same as returns the [`useMutation` hook](https://tanstack.com/query/latest/docs/framework/react/reference/useMutation))
99+
### hook `onError()`
83100

101+
Subscribe when mutation has been finished with failure
84102

103+
### method `reset()`
85104

105+
Reset current mutation
86106

107+
### property `result` <Badge type="info" text="observable.deep" />
87108

109+
Mutation result (The same as returns the [`useMutation` hook](https://tanstack.com/query/latest/docs/framework/react/reference/useMutation))

0 commit comments

Comments
 (0)