mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
Intermediate commit
This commit is contained in:
@@ -67,6 +67,10 @@ export const getSucceededRemoteData = () =>
|
||||
<T>(source: Observable<RemoteData<T>>): Observable<RemoteData<T>> =>
|
||||
source.pipe(find((rd: RemoteData<T>) => rd.hasSucceeded));
|
||||
|
||||
export const getSucceededRemoteWithNotEmptyData = () =>
|
||||
<T>(source: Observable<RemoteData<T>>): Observable<RemoteData<T>> =>
|
||||
source.pipe(find((rd: RemoteData<T>) => rd.hasSucceeded && isNotEmpty(rd.payload)));
|
||||
|
||||
/**
|
||||
* Get the first successful remotely retrieved object
|
||||
*
|
||||
@@ -84,6 +88,23 @@ export const getFirstSucceededRemoteDataPayload = () =>
|
||||
getRemoteDataPayload()
|
||||
);
|
||||
|
||||
/**
|
||||
* Get the first successful remotely retrieved object with not empty payload
|
||||
*
|
||||
* You usually don't want to use this, it is a code smell.
|
||||
* Work with the RemoteData object instead, that way you can
|
||||
* handle loading and errors correctly.
|
||||
*
|
||||
* These operators were created as a first step in refactoring
|
||||
* out all the instances where this is used incorrectly.
|
||||
*/
|
||||
export const getFirstSucceededRemoteDataWithNotEmptyPayload = () =>
|
||||
<T>(source: Observable<RemoteData<T>>): Observable<T> =>
|
||||
source.pipe(
|
||||
getSucceededRemoteWithNotEmptyData(),
|
||||
getRemoteDataPayload()
|
||||
);
|
||||
|
||||
/**
|
||||
* Get the all successful remotely retrieved objects
|
||||
*
|
||||
|
Reference in New Issue
Block a user