mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2024-06-14 11:52:32 +03:00
Provided fallback for failing instant load
This commit is contained in:
parent
71758b41b4
commit
58175137e2
@ -20,9 +20,10 @@
|
|||||||
* IN THE SOFTWARE.
|
* IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Observable } from "rxjs"
|
import { NEVER, Observable } from "rxjs"
|
||||||
import { ajax } from "rxjs/ajax"
|
import { ajax } from "rxjs/ajax"
|
||||||
import {
|
import {
|
||||||
|
catchError,
|
||||||
distinctUntilChanged,
|
distinctUntilChanged,
|
||||||
map,
|
map,
|
||||||
pluck,
|
pluck,
|
||||||
@ -32,7 +33,7 @@ import {
|
|||||||
switchMap
|
switchMap
|
||||||
} from "rxjs/operators"
|
} from "rxjs/operators"
|
||||||
|
|
||||||
import { getLocation } from "../../location"
|
import { getLocation, setLocation } from "../../location"
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------------
|
/* ----------------------------------------------------------------------------
|
||||||
* Helper types
|
* Helper types
|
||||||
@ -57,6 +58,8 @@ interface WatchOptions {
|
|||||||
* to the same page, the request is effectively ignored (i.e. when only the
|
* to the same page, the request is effectively ignored (i.e. when only the
|
||||||
* fragment identifier changes).
|
* fragment identifier changes).
|
||||||
*
|
*
|
||||||
|
* In case the request fails, the location change is dispatched regularly.
|
||||||
|
*
|
||||||
* @param options - Options
|
* @param options - Options
|
||||||
*
|
*
|
||||||
* @return Document switch observable
|
* @return Document switch observable
|
||||||
@ -77,8 +80,12 @@ export function watchDocumentSwitch(
|
|||||||
responseType: "document",
|
responseType: "document",
|
||||||
withCredentials: true
|
withCredentials: true
|
||||||
})
|
})
|
||||||
.pipe<Document>(
|
.pipe<Document, Document>(
|
||||||
pluck("response")
|
pluck("response"),
|
||||||
|
catchError(() => {
|
||||||
|
setLocation(url)
|
||||||
|
return NEVER
|
||||||
|
})
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
share()
|
share()
|
||||||
|
@ -36,6 +36,15 @@ export function getLocation(): string {
|
|||||||
return location.href
|
return location.href
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set location
|
||||||
|
*
|
||||||
|
* @param value - New location
|
||||||
|
*/
|
||||||
|
export function setLocation(value: string): void {
|
||||||
|
location.href = value
|
||||||
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------- */
|
/* ------------------------------------------------------------------------- */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user