1 year ago
#236037
Elliott Ives
Subscriptions to HTTP GET Requests No Longer Return Properly Typed Value in RxJS 7.5
So, here is my simple GET request:
async getInspectionForm(): Promise<Observable<InspectionSummaryFormField[]>> {
let params = new HttpParams();
params = params.append('InspectionType', this.inspection.InspectionType);
params = params.append('includeInactive', 'false');
const httpComponents = await this.httpService.composeRequest('/InspectionFormCriteria', params);
return this.http.get<InspectionSummaryFormField[]>(httpComponents.fullUrl, httpComponents.httpOptions); }
Here is where I consume the result:
this.inspectionFormCritera.subscribe(formCriteria => {
this.inspectionStorageService.inspectionFormCriteria = formCriteria;
for(const f of formCriteria) {
this.inspectionSummaryForm.addControl(f.FormInputName, new FormControl('', Validators.required));
this.saveValuesOnFormChange(f.FormInputName);
if(f.EndpointName) {
this.dropdownFieldIterator++;
}
if(f.RadioSelections) {
this.radioSelections.push(f.RadioSelections.split('-', 5)); // Because radio button selections are defined in the database like so: option1-option2-option3.
this.inspectionStorageService.formSelections.radioSelections = this.radioSelections;
}
}
this.prepareDropdownFields(formCriteria);
}, error => {
this.newInspectionsService.inspectionDownloadTimeoutError(error);
});
However, the above use of the subscription method is deprecated in my current version of RxJS 7.5 ... So I use the preferred syntax of moving the error handler into the error: () => {}
notifier function inside the subscribe call. However, my formCriteria object no longer unwraps from the observable with type InspectionSummaryFormField[], but instead with the 'any' type.
Is this just a beta issue or am I missing something important here?
angular
rxjs
angular-httpclient
rxjs7
0 Answers
Your Answer