I dont know how to use the value of the currently returned Observable of getUserHeaders()
in my http.get
.
Personally, the solution to my problem was to use BehaviorSubject
:
In service (source of the data):
private theBoolean: BehaviorSubject<boolean>;
constructor() {
this.theBoolean = new BehaviorSubject<boolean>(false);
}
public getTheBoolean(): Observable<boolean> {
return this.theBoolean.asObservable();
}
To emit new value of theBoolean do smth like
public setTheBoolean(newValue: boolean): void {
this.theBoolean.next(newValue);
}
In component (user of the data):
this.theService.getTheBoolean().subscribe(value => console.log(value));
Credit to "pashozator" on Reddit
Change your getUserHeaders()
to look like:
getUserHeaders(): Observable<any> { return Observable.of(NativeStorage.getItem("user"); }
Then construct your headers object within getParticipants()
. This way you can keep flatMap