mirror of https://github.com/OpenVidu/openvidu.git
ov-components: optimize participant name subscription with filter and tap operators
parent
76c957903f
commit
7bf0e0036c
|
@ -9,7 +9,7 @@ import {
|
|||
OnInit,
|
||||
Output
|
||||
} from '@angular/core';
|
||||
import { Subject, takeUntil } from 'rxjs';
|
||||
import { filter, Subject, takeUntil, tap } from 'rxjs';
|
||||
import { ILogger } from '../../models/logger.model';
|
||||
import { CdkOverlayService } from '../../services/cdk-overlay/cdk-overlay.service';
|
||||
import { OpenViduComponentsConfigService } from '../../services/config/directive-config.service';
|
||||
|
@ -138,12 +138,13 @@ export class PreJoinComponent implements OnInit, OnDestroy {
|
|||
|
||||
// Wait for the next tick to ensure the participant name propagates
|
||||
// through the observable before emitting onReadyToJoin
|
||||
const sub = this.libService.participantName$.pipe(takeUntil(this.destroy$)).subscribe((name) => {
|
||||
if (name === this.participantName) {
|
||||
this.onReadyToJoin.emit();
|
||||
sub.unsubscribe();
|
||||
}
|
||||
});
|
||||
this.libService.participantName$
|
||||
.pipe(
|
||||
takeUntil(this.destroy$),
|
||||
filter((name) => name === this.participantName),
|
||||
tap(() => this.onReadyToJoin.emit())
|
||||
)
|
||||
.subscribe();
|
||||
} else {
|
||||
// No participant name to set, emit immediately
|
||||
this.onReadyToJoin.emit();
|
||||
|
|
Loading…
Reference in New Issue