Fold map operation into combineLatest

This commit is contained in:
Robin
2025-06-25 13:38:47 -04:00
parent 131bdc3522
commit 3b1ce22b71

View File

@@ -269,21 +269,21 @@ class ControlledAudioOutput
this.deviceSelection$.next(id); this.deviceSelection$.next(id);
} }
public readonly selected$ = combineLatest([ public readonly selected$ = combineLatest(
this.available$, [
merge( this.available$,
controlledOutputSelection$.pipe(startWith(undefined)), merge(
this.deviceSelection$, controlledOutputSelection$.pipe(startWith(undefined)),
), this.deviceSelection$,
]).pipe( ),
map(([available, selectId]) => { ],
(available, selectId) => {
const id = selectId ?? available.keys().next().value; const id = selectId ?? available.keys().next().value;
return id return id
? { id, virtualEarpiece: id === EARPIECE_CONFIG_ID } ? { id, virtualEarpiece: id === EARPIECE_CONFIG_ID }
: undefined; : undefined;
}), },
this.scope.state(), ).pipe(this.scope.state());
);
public constructor(private readonly scope: ObservableScope) { public constructor(private readonly scope: ObservableScope) {
this.selected$.subscribe((device) => { this.selected$.subscribe((device) => {