Skip to content

Commit

Permalink
Return Observable if already stored
Browse files Browse the repository at this point in the history
  • Loading branch information
Yamaguchi committed Apr 24, 2024
1 parent 0697c43 commit a2c7a99
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions frontend/src/app/config.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,18 @@ export class ConfigService {
}

getConfig(): Observable<Config> {
if (this.config && this.observable) {
if (this.config) {
return new Observable(observer => {
observer.next(this.config);
observer.complete();
});
} else {
return (this.observable = this.loadConfig());
}

if (this.observable) {
return this.observable;
}

return (this.observable = this.loadConfig());
}

private loadConfig(): Observable<Config> {
Expand Down

0 comments on commit a2c7a99

Please sign in to comment.