polling functionality basically working, with direct call in main.ts

This commit is contained in:
Helmut Merz 2023-02-19 19:17:14 +01:00
parent d1eb02ee28
commit d9e0b54b80
2 changed files with 8 additions and 19 deletions

View file

@ -1,23 +1,25 @@
import { createApp } from './lib/petite-vue.es.js'
createApp({
const appdata = {
$delimiters: ['{|', '|}'],
urlParams: new URL(location.href).searchParams,
poll,
newdata: '',
data: '',
save
}).mount()
}
createApp(appdata).mount()
appdata.poll()
// method definitions
function save() {
this.data += '\n' + this.newdata
this.newdata = ''
}
//let pwait = new Promise(function(resolve, reject) {
// poll()
//})
function poll() {
fetch('http://localhost:8125/api/system/poll/service/pclt-0001')
.then((res) => res.json())
@ -30,15 +32,3 @@ function poll() {
return null
}
function Data() {
return {
data: '',
save(txt: string) {
this.data += '\n' + txt
}
}
}
// p = new URL(location.href).searchParams
// id = p.get('id')

View file

@ -1,3 +1,2 @@
{{ $js := resources.Get "js/main.ts" | js.Build (dict "minify" false) }}
<script src="{{ $js.Permalink }}" defer></script>
<div v-scope>{| poll() |}</div>