This commit is contained in:
Eugene Pankov
2021-06-14 23:00:05 +02:00
parent dc69574c07
commit e1425c6c80
32 changed files with 1502 additions and 422 deletions

View File

@@ -0,0 +1,24 @@
import { Subject } from 'rxjs'
import { debounceTime } from 'rxjs/operators'
import { HttpClient } from '@angular/common/http'
import { Injectable } from '@angular/core'
@Injectable({ providedIn: 'root' })
export class AppConnectorService {
config: any
private configUpdate = new Subject<string>()
constructor (private http: HttpClient) {
this.configUpdate.pipe(debounceTime(1000)).subscribe(content => {
this.http.patch(`/api/1/configs/${this.config.id}`, { content }).toPromise()
})
}
async loadConfig (): Promise<string> {
return this.config.content
}
async saveConfig (content: string): Promise<void> {
this.configUpdate.next(content)
}
}