[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:
parent
63d3b9777c
commit
eb5dad3b66
|
@ -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) {
|
||||||
|
|
Loading…
Reference in New Issue