mirror of
https://github.com/octoleo/syncthing.git
synced 2024-12-29 13:22:42 +00:00
complete observers
This commit is contained in:
parent
7d59dc6c18
commit
598dc991e8
@ -19,7 +19,8 @@ export class FolderService {
|
|||||||
getFolderStatusInOrder(observer: Subscriber<Folder>, startIndex: number) {
|
getFolderStatusInOrder(observer: Subscriber<Folder>, startIndex: number) {
|
||||||
// Return if there aren't any folders at the index
|
// Return if there aren't any folders at the index
|
||||||
if (startIndex >= (this.folders.length - 1)) {
|
if (startIndex >= (this.folders.length - 1)) {
|
||||||
return
|
observer.complete();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const folder: Folder = this.folders[startIndex];
|
const folder: Folder = this.folders[startIndex];
|
||||||
@ -41,7 +42,6 @@ export class FolderService {
|
|||||||
*/
|
*/
|
||||||
getAll(): Observable<Folder> {
|
getAll(): Observable<Folder> {
|
||||||
const folderObservable: Observable<Folder> = new Observable((observer) => {
|
const folderObservable: Observable<Folder> = new Observable((observer) => {
|
||||||
|
|
||||||
this.systemConfigService.getFolders().subscribe(
|
this.systemConfigService.getFolders().subscribe(
|
||||||
folders => {
|
folders => {
|
||||||
this.folders = folders;
|
this.folders = folders;
|
||||||
@ -49,7 +49,8 @@ export class FolderService {
|
|||||||
// Synchronously get the status of each folder
|
// Synchronously get the status of each folder
|
||||||
this.getFolderStatusInOrder(observer, 0);
|
this.getFolderStatusInOrder(observer, 0);
|
||||||
},
|
},
|
||||||
err => { console.log("getAll error!", err) }
|
err => { console.log("getAll error!", err) },
|
||||||
|
() => { console.log("get all complete!") }
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
return folderObservable
|
return folderObservable
|
||||||
|
@ -45,12 +45,14 @@ export class SystemConfigService {
|
|||||||
const folderObservable: Observable<Folder[]> = new Observable((observer) => {
|
const folderObservable: Observable<Folder[]> = new Observable((observer) => {
|
||||||
if (this.folders) {
|
if (this.folders) {
|
||||||
observer.next(this.folders);
|
observer.next(this.folders);
|
||||||
|
observer.complete();
|
||||||
} else {
|
} else {
|
||||||
// create timer to keep checking for folders
|
// create timer to keep checking for folders
|
||||||
let t = setInterval(() => {
|
let t = setInterval(() => {
|
||||||
if (this.folders) {
|
if (this.folders) {
|
||||||
clearInterval(t);
|
clearInterval(t);
|
||||||
observer.next(this.folders);
|
observer.next(this.folders)
|
||||||
|
observer.complete();
|
||||||
}
|
}
|
||||||
}, this.checkInterval);
|
}, this.checkInterval);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user