separate appdata from pvapp runner object
This commit is contained in:
parent
2dca568ee8
commit
126740ef14
1 changed files with 12 additions and 12 deletions
|
@ -15,30 +15,30 @@ export function config (api, polling): confdata {
|
|||
return { apiurl: api.path, pollurl: pu, itemid: urlparams.get('id') }
|
||||
}
|
||||
|
||||
export const pvapp = {
|
||||
const appdata = {
|
||||
$delimiters: ['{|', '|}'],
|
||||
conf: {} as confdata,
|
||||
data: {},
|
||||
output: '',
|
||||
run,
|
||||
save,
|
||||
poll,
|
||||
newdata: '',
|
||||
mounted(name: string) {
|
||||
console.log('app mounted: ', name)
|
||||
}
|
||||
}
|
||||
|
||||
// pvapp method definitions
|
||||
|
||||
function run(conf: confdata) {
|
||||
this.conf = conf
|
||||
createApp(this).mount()
|
||||
if (this.conf.pollurl) {
|
||||
this.poll()
|
||||
export const pvapp = {
|
||||
run(conf: confdata) {
|
||||
appdata.conf = conf
|
||||
createApp(appdata).mount()
|
||||
if (appdata.conf.pollurl) {
|
||||
appdata.poll()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// appdata method definitions
|
||||
|
||||
function save(value: string) {
|
||||
this.output += '\n' + value
|
||||
console.log('save:', value)
|
||||
|
@ -50,10 +50,10 @@ function poll() {
|
|||
|
||||
// basic functions
|
||||
|
||||
async function dopoll(app: typeof pvapp) {
|
||||
async function dopoll(app: typeof appdata) {
|
||||
while (true) {
|
||||
try {
|
||||
let res = await fetch(pvapp.conf.pollurl)
|
||||
let res = await fetch(app.conf.pollurl)
|
||||
let msg = await res.json()
|
||||
console.log(msg)
|
||||
//app.handle(msg)
|
||||
|
|
Loading…
Add table
Reference in a new issue