Hey everyone, can someone help me understand this situation?
Here is the code that's working:
this.sessionService.current$.subscribe(session => { console.log('WORKING', session); });
But this code is causing issues:
forkJoin([
this.sessionService.current$
])
.subscribe(([
session
]) => {
console.log('NOT WORKING', session);
...
After making a slight adjustment, it started working:
forkJoin([
this.sessionService.current$.pipe(take(1))
])
.subscribe(([
session
]) => {
console.log('WORKING', session);
...
The current$ property in SessionService is defined as follows:
private readonly subject$: Subject<Session> = new BehaviorSubject<Session>(null);
public readonly current$: Observable<Session> = this.subject$.asObservable();
There is an init()
method where I retrieve data over HTTP and emit it to this.subject$
;
Thank you for pointing me in the right direction!