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') }
 | 
						return { apiurl: api.path, pollurl: pu, itemid: urlparams.get('id') }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const pvapp = {
 | 
					const appdata = {
 | 
				
			||||||
	$delimiters: ['{|', '|}'],
 | 
						$delimiters: ['{|', '|}'],
 | 
				
			||||||
	conf: {} as confdata,
 | 
						conf: {} as confdata,
 | 
				
			||||||
	data: {},
 | 
						data: {},
 | 
				
			||||||
	output: '',
 | 
						output: '',
 | 
				
			||||||
	run,
 | 
					 | 
				
			||||||
	save,
 | 
						save,
 | 
				
			||||||
	poll,
 | 
						poll,
 | 
				
			||||||
	newdata: '',
 | 
					 | 
				
			||||||
	mounted(name: string) {
 | 
						mounted(name: string) {
 | 
				
			||||||
		console.log('app mounted: ', name)
 | 
							console.log('app mounted: ', name)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// pvapp method definitions
 | 
					export const pvapp = {
 | 
				
			||||||
 | 
						run(conf: confdata) {
 | 
				
			||||||
function run(conf: confdata) {
 | 
							appdata.conf = conf
 | 
				
			||||||
	this.conf = conf
 | 
							createApp(appdata).mount()
 | 
				
			||||||
	createApp(this).mount()
 | 
							if (appdata.conf.pollurl) {
 | 
				
			||||||
	if (this.conf.pollurl) {
 | 
								appdata.poll()
 | 
				
			||||||
		this.poll()
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// appdata method definitions
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function save(value: string) {
 | 
					function save(value: string) {
 | 
				
			||||||
	this.output += '\n' + value
 | 
						this.output += '\n' + value
 | 
				
			||||||
	console.log('save:', value)
 | 
						console.log('save:', value)
 | 
				
			||||||
| 
						 | 
					@ -50,10 +50,10 @@ function poll() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// basic functions
 | 
					// basic functions
 | 
				
			||||||
 | 
					
 | 
				
			||||||
async function dopoll(app: typeof pvapp) {
 | 
					async function dopoll(app: typeof appdata) {
 | 
				
			||||||
	while (true) {
 | 
						while (true) {
 | 
				
			||||||
		try {
 | 
							try {
 | 
				
			||||||
			let res = await fetch(pvapp.conf.pollurl)
 | 
								let res = await fetch(app.conf.pollurl)
 | 
				
			||||||
			let msg = await res.json()
 | 
								let msg = await res.json()
 | 
				
			||||||
			console.log(msg)
 | 
								console.log(msg)
 | 
				
			||||||
			//app.handle(msg)
 | 
								//app.handle(msg)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue