Merge branch 'master' into metadata-and-relationships-combined-in-submission

This commit is contained in:
Art Lowel
2020-06-22 11:50:44 +02:00
173 changed files with 8474 additions and 2423 deletions

View File

@@ -67,6 +67,10 @@ export const getSucceededRemoteData = () =>
<T>(source: Observable<RemoteData<T>>): Observable<RemoteData<T>> =>
source.pipe(filter((rd: RemoteData<T>) => rd.hasSucceeded), take(1));
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
*