From eb5dad3b66fe6623c04fc739bf49f420570d2e2a Mon Sep 17 00:00:00 2001 From: "k.triantafyllou" Date: Thu, 18 Apr 2019 12:47:26 +0000 Subject: [PATCH] [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 --- connect/communities/communities.service.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/connect/communities/communities.service.ts b/connect/communities/communities.service.ts index c42082a4..eae9c9d0 100644 --- a/connect/communities/communities.service.ts +++ b/connect/communities/communities.service.ts @@ -3,11 +3,25 @@ import {Http} from '@angular/http'; import {CommunityInfo} from '../community/communityInfo'; import {EnvProperties} from '../../utils/properties/env-properties'; +import {BehaviorSubject, Observable} from "rxjs"; @Injectable() export class CommunitiesService { + public communities: BehaviorSubject = null; + 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) {