So I have a service function which currently looks like this - It is not working, but I feel like its probably close
deactivateSegment(id, isUsingName?){
if(isUsingName) {
return this.getSpecificSegment(id).pipe(concatMap((res: any) => {
return this.deactivateSegment(res.data.segmentID)
}))
} else {
return this._http.patch(`${this.baseUrl}/segments/${id}/deactivate`, {})
}
}
This function can either be called with either an ID or a name as the parameter. If it is called with a name as the parameter, we use the first block of the if statement to first make a call to get the ID, and then use that response to recursively call the deactivateSegment function using the ID rather than the name.
Currently this isn't working as expected though. I think its not returning the correct observable. It seems to just return the getSpecificSegment and then the inner observable doesn't execute, or something like that.