import { createApp } from './lib/petite-vue.es.js' import { pageid } from '@params' console.log("pageid:", pageid) import { api, polling } from './settings' import { config, pvapp } from './common' // pvapp.run(config(api, polling)) const pollUrl = `${api.path}/${polling.msgbase.join('/')}` console.log("pollUrl:", pollUrl) const appdata = { $delimiters: ['{|', '|}'], urlParams: new URL(location.href).searchParams, poll, newdata: '', data: '', save, mounted(name: string) { console.log('app mounted: ', name) } } createApp(appdata).mount() appdata.poll() // method definitions function save() { this.data += '\n' + this.newdata this.newdata = '' } async function dopoll(obj: typeof appdata, url: string) { while (true) { try { let res = await fetch(url) let data = await res.json() console.log(data) obj.newdata = data['status'] } catch (error) { console.log(error) await new Promise(r => setTimeout(r, 10000)) } } } function poll() { dopoll(this, pollUrl) }