Added more inline comments and simplified component mounting

This commit is contained in:
squidfunk
2021-02-13 17:03:15 +01:00
parent 96797b471f
commit aacb5ca5a7
45 changed files with 155 additions and 84 deletions

View File

@@ -67,19 +67,19 @@ export function watchPrint(): Observable<void> {
/* ------------------------------------------------------------------------- */
/**
* Toggle an observable with another one
* Toggle an observable with a media observable
*
* @template T - Data type
*
* @param toggle$ - Toggle observable
* @param query$ - Media observable
* @param factory - Observable factory
*
* @returns Toggled observable
*/
export function at<T>(
toggle$: Observable<boolean>, factory: () => Observable<T>
query$: Observable<boolean>, factory: () => Observable<T>
): Observable<T> {
return toggle$
return query$
.pipe(
switchMap(active => active ? factory() : NEVER)
)