[Trunk|Library]: Remove subject from curators service.

git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@55998 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
k.triantafyllou 2019-06-05 14:21:38 +00:00
parent 779be7dd43
commit 8b8c02eab9
1 changed files with 3 additions and 21 deletions

View File

@ -1,6 +1,6 @@
import {Injectable} from '@angular/core'; import {Injectable} from '@angular/core';
import {HttpClient} from '@angular/common/http'; import {HttpClient} from '@angular/common/http';
import {BehaviorSubject, Observable} from 'rxjs'; import {Observable} from 'rxjs';
import {Curator} from '../../utils/entities/CuratorInfo'; import {Curator} from '../../utils/entities/CuratorInfo';
import {EnvProperties} from '../../utils/properties/env-properties'; import {EnvProperties} from '../../utils/properties/env-properties';
import {CustomOptions} from "../../services/servicesUtils/customOptions.class"; import {CustomOptions} from "../../services/servicesUtils/customOptions.class";
@ -8,29 +8,11 @@ import {CustomOptions} from "../../services/servicesUtils/customOptions.class";
@Injectable() @Injectable()
export class CuratorService { export class CuratorService {
private curatorsSubject: BehaviorSubject<Curator[]> = new BehaviorSubject([]);
constructor(private http: HttpClient) { constructor(private http: HttpClient) {
} }
public initCurators(properties: EnvProperties, url: string): void { public getCurators(properties: EnvProperties, url: string): Observable<Curator[]> {
this.http.get<Curator[]>((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url). return this.http.get<Curator[]>((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url);
subscribe((curators) => {
this.curatorsSubject.next(curators);
});
}
public get curators(): Observable<Curator[]> {
return this.curatorsSubject.asObservable();
}
public updateCurators(curator: Curator) {
const curators = this.curatorsSubject.value;
if (curators && curator) {
curator._id = null;
curators.push(curator);
this.curatorsSubject.next(curators);
}
} }
public updateCurator(url: string, curator: Curator) { public updateCurator(url: string, curator: Curator) {