feat: move testing code to js-sandbox

This commit is contained in:
Andrew Bastin
2021-09-25 01:09:48 +05:30
parent 166f9e817b
commit 9454d8c100
4 changed files with 98 additions and 499 deletions

View File

@@ -232,6 +232,7 @@
<script setup lang="ts">
import { computed, ref, useContext, watch } from "@nuxtjs/composition-api"
import { isRight } from "fp-ts/lib/Either"
import {
updateRESTResponse,
restEndpoint$,
@@ -303,25 +304,30 @@ watch(loading, () => {
}
})
const newSendRequest = () => {
const newSendRequest = async () => {
loading.value = true
subscribeToStream(
runRESTRequest$(),
(responseState) => {
if (loading.value) {
// Check exists because, loading can be set to false
// when cancelled
updateRESTResponse(responseState)
const streamResult = await runRESTRequest$()
// TODO: What if stream fetching failed (script execution errors ?) (isLeft)
if (isRight(streamResult)) {
subscribeToStream(
streamResult.right,
(responseState) => {
if (loading.value) {
// Check exists because, loading can be set to false
// when cancelled
updateRESTResponse(responseState)
}
},
() => {
loading.value = false
},
() => {
loading.value = false
}
},
() => {
loading.value = false
},
() => {
loading.value = false
}
)
)
}
}
const cancelRequest = () => {