summaryrefslogtreecommitdiff
path: root/opendc-web/opendc-web-ui/src/data/experiments.js
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2021-07-07 20:13:30 +0200
committerFabian Mastenbroek <mail.fabianm@gmail.com>2021-07-08 10:53:23 +0200
commit02a2f0f89cb1f39a5f8856bca1971a4e1b12374f (patch)
treedcea2fb2f46f47b0f5a961a52023510d227b5936 /opendc-web/opendc-web-ui/src/data/experiments.js
parent9c8a987556d0fb0cdf0eb67e0c191a8dcc5593b9 (diff)
ui: Use React Query defaults to reduce duplication
Diffstat (limited to 'opendc-web/opendc-web-ui/src/data/experiments.js')
-rw-r--r--opendc-web/opendc-web-ui/src/data/experiments.js15
1 files changed, 10 insertions, 5 deletions
diff --git a/opendc-web/opendc-web-ui/src/data/experiments.js b/opendc-web/opendc-web-ui/src/data/experiments.js
index 4797bacb..a76ea53f 100644
--- a/opendc-web/opendc-web-ui/src/data/experiments.js
+++ b/opendc-web/opendc-web-ui/src/data/experiments.js
@@ -22,21 +22,26 @@
import { useQuery } from 'react-query'
import { fetchTraces } from '../api/traces'
-import { useAuth } from '../auth'
import { fetchSchedulers } from '../api/schedulers'
/**
+ * Configure the query defaults for the experiment endpoints.
+ */
+export function configureExperimentClient(queryClient, auth) {
+ queryClient.setQueryDefaults('traces', { queryFn: () => fetchTraces(auth) })
+ queryClient.setQueryDefaults('schedulers', { queryFn: () => fetchSchedulers(auth) })
+}
+
+/**
* Return the available traces to experiment with.
*/
export function useTraces() {
- const auth = useAuth()
- return useQuery('traces', () => fetchTraces(auth))
+ return useQuery('traces')
}
/**
* Return the available schedulers to experiment with.
*/
export function useSchedulers() {
- const auth = useAuth()
- return useQuery('schedulers', () => fetchSchedulers(auth))
+ return useQuery('schedulers')
}