@codonsplice/vue 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +25 -0
- package/package.json +9 -0
package/index.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// @codonsplice/vue — a useSpliceQL() composable over @codonsplice/wasm.
|
|
2
|
+
import { ref } from 'vue'
|
|
3
|
+
import { execute as csExecute } from '../index.js'
|
|
4
|
+
|
|
5
|
+
export function useSpliceQL() {
|
|
6
|
+
const result = ref(null)
|
|
7
|
+
const error = ref(null)
|
|
8
|
+
const loading = ref(false)
|
|
9
|
+
|
|
10
|
+
async function execute({ query, files, vars }) {
|
|
11
|
+
loading.value = true
|
|
12
|
+
error.value = null
|
|
13
|
+
try {
|
|
14
|
+
result.value = await csExecute({ query, files, vars })
|
|
15
|
+
return result.value
|
|
16
|
+
} catch (e) {
|
|
17
|
+
error.value = e
|
|
18
|
+
throw e
|
|
19
|
+
} finally {
|
|
20
|
+
loading.value = false
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return { execute, result, error, loading }
|
|
25
|
+
}
|