[Trunk|Library]: Communities Service: Add a subject to keep communities, a method to update them from the API and a method to get subject as Observable

git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@55400 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
k.triantafyllou 2019-04-18 12:47:26 +00:00
parent 63d3b9777c
commit eb5dad3b66
1 changed files with 14 additions and 0 deletions

View File

@ -3,11 +3,25 @@ import {Http} from '@angular/http';
import {CommunityInfo} from '../community/communityInfo'; import {CommunityInfo} from '../community/communityInfo';
import {EnvProperties} from '../../utils/properties/env-properties'; import {EnvProperties} from '../../utils/properties/env-properties';
import {BehaviorSubject, Observable} from "rxjs";
@Injectable() @Injectable()
export class CommunitiesService { export class CommunitiesService {
public communities: BehaviorSubject<CommunityInfo[]> = null;
constructor(private http: Http) { constructor(private http: Http) {
this.communities = new BehaviorSubject([]);
}
updateCommunities(properties: EnvProperties, url: string) {
this.getCommunities(properties, url).subscribe(res => {
this.communities.next(res);
})
}
getCommunitiesState() {
return this.communities.asObservable();
} }
getCommunities(properties: EnvProperties, url: string) { getCommunities(properties: EnvProperties, url: string) {