Skip to content

Commit 8dce9a3

Browse files
committed
docs: update docs for enableOnDemand option
1 parent 1358878 commit 8dce9a3

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,29 @@ const query = new MobxQuery({
5454
query.result.data; // from this code line query starts fetching data
5555
```
5656

57+
This option works as is if query will be "enabled", otherwise you should enable this query.
58+
```ts
59+
const query = new MobxQuery({
60+
enabled: false,
61+
enableOnDemand: true,
62+
queryFn: () => {},
63+
});
64+
query.result.data; // nothing happened because query is disabled.
65+
```
66+
But if you set `enabled` as `true` and option `enableOnDemand` will be `true` too then query will be fetched only after user will try to get access to result.
67+
```ts
68+
const query = new MobxQuery({
69+
enabled: true,
70+
enableOnDemand: true,
71+
queryFn: () => {},
72+
});
73+
...
74+
// query is not fetched
75+
...
76+
// query is not fetched
77+
query.result.data; // query starts execute the queryFn
78+
```
79+
5780
#### dynamic `options`
5881
Options which can be dynamically updated for this query
5982

0 commit comments

Comments
 (0)