Replaced deprecated RxJS operators

This commit is contained in:
squidfunk
2022-04-02 18:36:59 +02:00
parent f4f9c21d32
commit 92dc0375dc
19 changed files with 68 additions and 71 deletions

View File

@@ -25,7 +25,7 @@ import {
Observable,
fromEvent,
fromEventPattern,
mapTo,
map,
merge,
startWith,
switchMap
@@ -65,8 +65,8 @@ export function watchMedia(query: string): Observable<boolean> {
export function watchPrint(): Observable<boolean> {
const media = matchMedia("print")
return merge(
fromEvent(window, "beforeprint").pipe(mapTo(true)),
fromEvent(window, "afterprint").pipe(mapTo(false))
fromEvent(window, "beforeprint").pipe(map(() => true)),
fromEvent(window, "afterprint").pipe(map(() => false))
)
.pipe(
startWith(media.matches)

View File

@@ -25,7 +25,7 @@ import {
defer,
finalize,
fromEvent,
mapTo,
map,
merge,
switchMap,
take,
@@ -62,7 +62,7 @@ export function watchScript(src: string): Observable<void> {
)
)
.pipe(
mapTo(undefined),
map(() => undefined),
finalize(() => document.head.removeChild(script)),
take(1)
)

View File

@@ -26,7 +26,7 @@ import {
fromEvent,
map,
share,
switchMapTo,
switchMap,
tap,
throttle
} from "rxjs"
@@ -100,7 +100,7 @@ export function watchWorker<T extends WorkerMessage>(
.pipe(
throttle(() => rx$, { leading: true, trailing: true }),
tap(message => worker.postMessage(message)),
switchMapTo(rx$),
switchMap(() => rx$),
share()
)
}

View File

@@ -22,7 +22,7 @@
import {
Observable,
mapTo,
map,
of,
shareReplay,
tap
@@ -94,7 +94,7 @@ export function mountMermaid(
startOnLoad: false,
themeCSS
})),
mapTo(undefined),
map(() => undefined),
shareReplay(1)
)
@@ -117,6 +117,6 @@ export function mountMermaid(
/* Create and return component */
return mermaid$
.pipe(
mapTo({ ref: el })
map(() => ({ ref: el }))
)
}

View File

@@ -27,7 +27,6 @@ import {
filter,
finalize,
map,
mapTo,
merge,
tap
} from "rxjs"
@@ -89,7 +88,9 @@ export function watchDetails(
.pipe(
map(target => target.closest("details:not([open])")!),
filter(details => el === details),
mapTo<Details>({ action: "open", reveal: true })
map(() => ({
action: "open", reveal: true
}) as Details)
),
/* Open details on print and close afterwards */

View File

@@ -31,7 +31,6 @@ import {
finalize,
fromEvent,
map,
mapTo,
merge,
startWith,
subscribeOn,
@@ -79,9 +78,9 @@ export function watchContentTabs(
const active = inputs.find(input => input.checked) || inputs[0]
return merge(...inputs.map(input => fromEvent(input, "change")
.pipe(
mapTo<ContentTabs>({
map(() => ({
active: getElement(`label[for=${input.id}]`)
})
}) as ContentTabs)
)
))
.pipe(

View File

@@ -28,7 +28,6 @@ import {
finalize,
fromEvent,
map,
mapTo,
mergeMap,
observeOn,
of,
@@ -87,7 +86,7 @@ export function watchPalette(
.pipe(
mergeMap(input => fromEvent(input, "change")
.pipe(
mapTo(input)
map(() => input)
)
),
startWith(inputs[Math.max(0, current.index)]),

View File

@@ -24,7 +24,7 @@ import ClipboardJS from "clipboard"
import {
Observable,
Subject,
mapTo,
map,
tap
} from "rxjs"
@@ -89,7 +89,7 @@ export function setupClipboardJS(
const trigger = ev.trigger as HTMLElement
trigger.focus()
}),
mapTo(translation("clipboard.copied"))
map(() => translation("clipboard.copied"))
)
.subscribe(alert$)
}

View File

@@ -28,8 +28,7 @@ import {
fromEvent,
map,
of,
switchMap,
switchMapTo
switchMap
} from "rxjs"
import { configuration } from "~/_"
@@ -135,7 +134,7 @@ export function setupVersionSelector(
})
/* Integrate outdated version banner with instant loading */
document$.pipe(switchMapTo(current$))
document$.pipe(switchMap(() => current$))
.subscribe(current => {
/* Check if version state was already determined */

View File

@@ -23,7 +23,7 @@
import {
Observable,
fromEvent,
mapTo,
map,
mergeMap,
switchMap,
takeWhile,
@@ -72,7 +72,7 @@ export function patchIndeterminate(
mergeMap(el => fromEvent(el, "change")
.pipe(
takeWhile(() => el.hasAttribute("data-md-state")),
mapTo(el)
map(() => el)
)
),
withLatestFrom(tablet$)

View File

@@ -24,7 +24,7 @@ import {
Observable,
filter,
fromEvent,
mapTo,
map,
mergeMap,
switchMap,
tap
@@ -81,7 +81,7 @@ export function patchScrollfix(
filter(isAppleDevice),
mergeMap(el => fromEvent(el, "touchstart")
.pipe(
mapTo(el)
map(() => el)
)
)
)