Explain why we use merge

This commit is contained in:
Johannes Marbach
2026-10-08 11:14:26 +02:00
parent 53e038b09b
commit 4fd2f66949
+10
View File
@@ -1164,6 +1164,16 @@ export function createCallViewModel$(
* The media to be used to produce a layout. * The media to be used to produce a layout.
*/ */
const layoutMedia$ = scope.behavior<LayoutMedia>( const layoutMedia$ = scope.behavior<LayoutMedia>(
// We deliberately don't use combineLatest here. Several of the inputs
// below derive from the same source. So one upstream change cascades
// through them one at a time. combineLatest would see each step of the
// cascade and emit layouts built from inputs that never coexisted.
// Instead, we treat the emissions as a mere "something changed" signal
// and read every input's current value. The derived behaviors were
// subscribed before this one and a BehaviorSubject updates its value
// before notifying. So by the time the first signal arrives every value
// is already consistent. The duplicate signals from the rest of the
// cascade are dropped by distinctUntilChanged.
merge( merge(
windowMode$, windowMode$,
layoutSwitchVm.layout$, layoutSwitchVm.layout$,