added test and docs for 404 operator

This commit is contained in:
lotte
2019-05-09 13:39:24 +02:00
parent ee5a9c7df5
commit 187c70847c
9 changed files with 55 additions and 20 deletions

View File

@@ -64,7 +64,12 @@ export const getSucceededRemoteData = () =>
<T>(source: Observable<RemoteData<T>>): Observable<RemoteData<T>> =>
source.pipe(find((rd: RemoteData<T>) => rd.hasSucceeded));
export const renderPageNotFoundOn404 = (router: Router) =>
/**
* Operator that checks if a remote data object contains a page not found error
* When it does contain such an error, it will redirect the user to a page not found, without altering the current URL
* @param router The router used to navigate to a new page
*/
export const redirectToPageNotFoundOn404 = (router: Router) =>
<T>(source: Observable<RemoteData<T>>): Observable<RemoteData<T>> =>
source.pipe(
tap((rd: RemoteData<T>) => {