Use finnish notation for observables (#2905)
To help make our usage of the observables more readable/intuitive.
This commit is contained in:
@@ -18,16 +18,16 @@ import {
|
||||
* Require 1 second of continuous speaking to become a speaker, and 60 second of
|
||||
* continuous silence to stop being considered a speaker
|
||||
*/
|
||||
export function observeSpeaker(
|
||||
isSpeakingObservable: Observable<boolean>,
|
||||
export function observeSpeaker$(
|
||||
isSpeakingObservable$: Observable<boolean>,
|
||||
): Observable<boolean> {
|
||||
const distinct = isSpeakingObservable.pipe(distinctUntilChanged());
|
||||
const distinct$ = isSpeakingObservable$.pipe(distinctUntilChanged());
|
||||
|
||||
return distinct.pipe(
|
||||
return distinct$.pipe(
|
||||
// Either change to the new value after the timer or re-emit the same value if it toggles back
|
||||
// (audit will return the latest (toggled back) value) before the timeout.
|
||||
audit((s) =>
|
||||
merge(timer(s ? 1000 : 60000), distinct.pipe(filter((s1) => s1 !== s))),
|
||||
merge(timer(s ? 1000 : 60000), distinct$.pipe(filter((s1) => s1 !== s))),
|
||||
),
|
||||
// Filter the re-emissions (marked as: | ) that happen if we toggle quickly (<1s) from false->true->false|->..
|
||||
startWith(false),
|
||||
|
||||
Reference in New Issue
Block a user