@codonsplice/svelte 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 +26 -0
- package/package.json +9 -0
package/index.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// @codonsplice/svelte — a createSpliceQL() store factory over @codonsplice/wasm.
|
|
2
|
+
import { writable } from 'svelte/store'
|
|
3
|
+
import { execute as csExecute } from '../index.js'
|
|
4
|
+
|
|
5
|
+
export function createSpliceQL() {
|
|
6
|
+
const result = writable(null)
|
|
7
|
+
const error = writable(null)
|
|
8
|
+
const loading = writable(false)
|
|
9
|
+
|
|
10
|
+
async function execute({ query, files, vars }) {
|
|
11
|
+
loading.set(true)
|
|
12
|
+
error.set(null)
|
|
13
|
+
try {
|
|
14
|
+
const r = await csExecute({ query, files, vars })
|
|
15
|
+
result.set(r)
|
|
16
|
+
return r
|
|
17
|
+
} catch (e) {
|
|
18
|
+
error.set(e)
|
|
19
|
+
throw e
|
|
20
|
+
} finally {
|
|
21
|
+
loading.set(false)
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return { execute, result, error, loading }
|
|
26
|
+
}
|