0

I am new to Angular 6 and having hard time grasping MergeMap and ConcatMap. What i'm trying to achieve is making an API call that returns following example:

JSON object

Json object

I need to take all the inputDatasets.datasetName comma separated to a string and make another api call with that api call will return inputDatasets.version array to update the first API call. I see so many different uses of map and pipe and mergeMap concatMap and little overwhelmed as to which to use and how to implement.

1 Answer 1

1

I would use switchMap

service.getSpreadSheetdata().pipe(
    map(spreadSheetdata => transformSpreadSheetdata(spreadSheetdata)),
    switchMap(transformedSpreadSheetdata => service.apiCall(transformedSpreadSheetdata))
).subscribe(apiData => doStuffWithApiData(apiData));

Call the method to get the spread sheet data, then map it to the shape you need for the api call and then switch map the transformed data to pass it down to the api call.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.