Updated Feed Enpoint Token to string | Observable<string>

This commit is contained in:
Lorenz Hilpert
2019-02-06 13:37:23 +01:00
parent 89f709d48f
commit a2736cefdb
2 changed files with 16 additions and 3 deletions

View File

@@ -2,14 +2,26 @@ import { Injectable, Inject } from '@angular/core';
import { FEED_SERVICE_ENDPOINT } from './tokens';
import { PagedApiResponse } from './response';
import { FeedDTO } from './dtos/feed.dto';
import { Observable } from 'rxjs';
import { Observable, isObservable } from 'rxjs';
import { HttpClient } from '@angular/common/http';
import { StringDictionary } from './models';
import { isNumber } from 'util';
@Injectable({ providedIn: 'root' })
export class FeedService {
constructor(@Inject(FEED_SERVICE_ENDPOINT) private endpoint: string, private http: HttpClient) { }
endpoint = '';
constructor(
private http: HttpClient,
@Inject(FEED_SERVICE_ENDPOINT) endpoint: string | Observable<string>
) {
if (isObservable(endpoint)) {
endpoint.subscribe(e => this.endpoint = e);
} else {
this.endpoint = endpoint;
}
}
info(options?: { skip?: number; take?: number; }): Observable<PagedApiResponse<FeedDTO>> {

View File

@@ -1,3 +1,4 @@
import { InjectionToken } from '@angular/core';
import { Observable } from 'rxjs';
export const FEED_SERVICE_ENDPOINT = new InjectionToken<string>('feed:service:endpoint');
export const FEED_SERVICE_ENDPOINT = new InjectionToken<string | Observable<string>>('feed:service:endpoint');