Folks, can anyone explain this behaviour?
This is working:
this.sessionService.current$.subscribe(session => { console.log('WORKING', session); });
But this is NOT working:
forkJoin([
this.sessionService.current$
])
.subscribe(([
session
]) => {
console.log('NOT WORKING', session);
...
After a little change got it working:
forkJoin([
this.sessionService.current$.pipe(take(1))
])
.subscribe(([
session
]) => {
console.log('WORKING', session);
...
current$ property in SessionService is defined like this:
private readonly subject$: Subject<Session> = new BehaviorSubject<Session>(null);
public readonly current$: Observable<Session> = this.subject$.asObservable();
there is then a init()
method where I GET
data over http and emit to this.subject$
;
Thanks a lot for a right direction!
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…