polling functionality basically working, with direct call in main.ts
This commit is contained in:
		
							parent
							
								
									d1eb02ee28
								
							
						
					
					
						commit
						d9e0b54b80
					
				
					 2 changed files with 8 additions and 19 deletions
				
			
		|  | @ -1,23 +1,25 @@ | ||||||
| import { createApp } from './lib/petite-vue.es.js' | import { createApp } from './lib/petite-vue.es.js' | ||||||
| 
 | 
 | ||||||
| createApp({ | const appdata = { | ||||||
| 	$delimiters: ['{|', '|}'], | 	$delimiters: ['{|', '|}'], | ||||||
| 	urlParams: new URL(location.href).searchParams, | 	urlParams: new URL(location.href).searchParams, | ||||||
| 	poll, | 	poll, | ||||||
| 	newdata: '', | 	newdata: '', | ||||||
| 	data: '', | 	data: '', | ||||||
| 	save | 	save | ||||||
| }).mount() | } | ||||||
|  | 
 | ||||||
|  | createApp(appdata).mount() | ||||||
|  | 
 | ||||||
|  | appdata.poll() | ||||||
|  | 
 | ||||||
|  | // method definitions
 | ||||||
| 
 | 
 | ||||||
| function save() { | function save() { | ||||||
| 	this.data += '\n' + this.newdata | 	this.data += '\n' + this.newdata | ||||||
| 	this.newdata = '' | 	this.newdata = '' | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| //let pwait = new Promise(function(resolve, reject) {
 |  | ||||||
| //	poll()
 |  | ||||||
| //})
 |  | ||||||
| 
 |  | ||||||
| function poll() { | function poll() { | ||||||
| 		fetch('http://localhost:8125/api/system/poll/service/pclt-0001') | 		fetch('http://localhost:8125/api/system/poll/service/pclt-0001') | ||||||
| 			.then((res) => res.json()) | 			.then((res) => res.json()) | ||||||
|  | @ -30,15 +32,3 @@ function poll() { | ||||||
| 	return null | 	return null | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| function Data() { |  | ||||||
| 	return { |  | ||||||
| 		data: '', |  | ||||||
| 		save(txt: string) { |  | ||||||
| 			this.data += '\n' + txt |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| // p = new URL(location.href).searchParams
 |  | ||||||
| // id = p.get('id')
 |  | ||||||
| 
 |  | ||||||
|  |  | ||||||
|  | @ -1,3 +1,2 @@ | ||||||
| {{ $js := resources.Get "js/main.ts" | js.Build (dict "minify" false) }} | {{ $js := resources.Get "js/main.ts" | js.Build (dict "minify" false) }} | ||||||
| <script src="{{ $js.Permalink }}" defer></script> | <script src="{{ $js.Permalink }}" defer></script> | ||||||
| <div v-scope>{| poll() |}</div> |  | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		
		Reference in a new issue