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

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -214,7 +214,7 @@
</script>
{% endblock %}
{% block scripts %}
<script src="{{ 'assets/javascripts/bundle.ce0c0ed4.min.js' | url }}"></script>
<script src="{{ 'assets/javascripts/bundle.52fb055a.min.js' | url }}"></script>
{% for path in config["extra_javascript"] %}
<script src="{{ path | url }}"></script>
{% endfor %}

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)
)
)
)

View File

@ -30,7 +30,7 @@ import {
identity,
catchError,
defer,
mapTo,
map,
mergeWith,
of,
switchMap,
@ -144,7 +144,7 @@ export function watch(
export function mkdir(directory: string): Observable<string> {
return defer(() => fs.mkdir(directory, { recursive: true }))
.pipe(
mapTo(directory)
map(() => directory)
)
}
@ -176,7 +176,7 @@ export function write(file: string, data: string): Observable<string> {
cache.set(file, data)
return defer(() => fs.writeFile(file, data))
.pipe(
mapTo(file),
map(() => file),
process.argv.includes("--verbose")
? tap(file => console.log(`${now()} + ${file}`))
: identity

View File

@ -25,7 +25,7 @@ import * as path from "path"
import {
Observable,
from,
mapTo,
map,
mergeMap,
switchMap
} from "rxjs"
@ -82,7 +82,7 @@ export function copy(
switchMap(data => write(options.to, data))
)
),
mapTo(options.to)
map(() => options.to)
)
}

View File

@ -34,7 +34,6 @@ import {
scan,
startWith,
switchMap,
switchMapTo,
toArray,
zip
} from "rxjs"
@ -189,7 +188,7 @@ const manifest$ = merge(
)
.pipe(
startWith("*"),
switchMapTo(observable$.pipe(toArray()))
switchMap(() => observable$.pipe(toArray()))
)
))
)