Skip to content

Commit 323bf50

Browse files
committed
feat: context sharing (#188)
1 parent 348f580 commit 323bf50

File tree

8 files changed

+1147
-12
lines changed

8 files changed

+1147
-12
lines changed

examples/multi-page/index.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@
55
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
66
<title>Vue-query example</title>
77
</head>
8-
<body>
8+
<body style="display:flex;">
99
<div id="app"></div>
10+
<br />
11+
<div id="app2"></div>
1012
<script type="module" src="/src/main.ts"></script>
1113
</body>
1214
</html>

examples/multi-page/src/Page.vue

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ export default defineComponent({
3030
cacheTime: 4000,
3131
}
3232
);
33-
useQuery("todos2", todoFetcher);
34-
useQuery("todos3", todoFetcher);
3533
3634
return { isLoading, isError, isFetching, data, error, refetch };
3735
},

examples/multi-page/src/main.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
import { createApp } from "vue";
2-
import { VueQueryPlugin } from "vue-query";
2+
import { VueQueryPlugin, VueQueryPluginOptions } from "vue-query";
33

44
import App from "./App.vue";
55

6-
createApp(App).use(VueQueryPlugin).mount("#app");
6+
createApp(App)
7+
.use(VueQueryPlugin, { contextSharing: true } as VueQueryPluginOptions)
8+
.mount("#app");
9+
// Second app mounted here will share vue-query context with the first app - click refresh to refresh both apps state
10+
createApp(App)
11+
.use(VueQueryPlugin, { contextSharing: true } as VueQueryPluginOptions)
12+
.mount("#app2");

jest.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const config: Config.InitialOptions = {
99
moduleNameMapper: {
1010
"^vue-query": "<rootDir>/src/index.ts",
1111
},
12+
testEnvironment: "jsdom",
1213
testPathIgnorePatterns: ["test-utils.ts"],
1314
collectCoverage: true,
1415
collectCoverageFrom: [

0 commit comments

Comments
 (0)