rxjs/operators#takeUntil JavaScript Examples
The following examples show how to use
rxjs/operators#takeUntil.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: index.js From discovery-mobile-ui with MIT License | 6 votes |
initializeFhirClient = (action$, state$, { fhirClient }) => action$.pipe(
ofType(actionTypes.SET_AUTH),
// delay(5000), // e.g.: for debugging -- import delay from rxjs/operators
concatMap(({ payload }) => {
if (payload === MOCK_AUTH) {
return Promise.resolve({
type: actionTypes.FHIR_FETCH_SUCCESS,
payload: MOCK_BUNDLE,
});
}
return from(fhirClient.queryPatient())
.pipe(
mergeMap((requestFn) => from(requestFn()).pipe(
rxMap((result) => ({
type: actionTypes.FHIR_FETCH_SUCCESS,
payload: result,
})),
catchError((error) => handleError(error, 'Error in queryPatient', actionTypes.FHIR_FETCH_ERROR)),
)),
);
}),
takeUntil(action$.pipe(ofType(actionTypes.CLEAR_PATIENT_DATA))),
repeat(),
catchError((error) => handleError(error, 'Error in initializeFhirClient switchMap')),
)
Example #2
Source File: index.js From discovery-mobile-ui with MIT License | 6 votes |
requestNextItems = (action$, state$, { fhirClient }) => action$.pipe(
ofType(actionTypes.FHIR_FETCH_SUCCESS),
// delay(1000), // e.g.: for debugging
concatMap(({ payload }) => from(extractNextUrls(payload)).pipe(
concatMap((url) => fhirClient.request(url)),
).pipe(
rxMap((result) => ({
type: actionTypes.FHIR_FETCH_SUCCESS,
payload: result,
})),
catchError((error) => handleError(error, 'Error in requestNextItems nextRequests$.pipe')),
)),
takeUntil(action$.pipe(ofType(actionTypes.CLEAR_PATIENT_DATA))),
repeat(),
catchError((error) => handleError(error, 'Error in requestNextItems concatMap')),
)
Example #3
Source File: index.js From discovery-mobile-ui with MIT License | 6 votes |
resolveReferences = (action$, state$, { fhirClient }) => action$.pipe(
ofType(actionTypes.RESOURCE_BATCH),
// delay(1000), // e.g.: for debugging
concatMap(({ payload }) => from(extractReferences(payload))
.pipe(
mergeMap(({
referenceUrn, context, // referenceType, parentType,
}) => from(fhirClient.resolve({ reference: referenceUrn, context })).pipe(
// tap(() => console.log('Silent success referenceUrn', referenceUrn)),
rxMap((result) => ({
type: actionTypes.FHIR_FETCH_SUCCESS,
payload: result,
})),
catchError((error) => handleError(error, `Error in resolveReferences fhirClient.resolve urn:\n ${referenceUrn}`)),
)),
)),
takeUntil(action$.pipe(ofType(actionTypes.CLEAR_PATIENT_DATA))),
repeat(),
catchError((error) => handleError(error, 'Error in resolveReferences')),
)