0

I have two components Parent and child.

In parent there is HTTP call and there is a switchMap operator. Inside the loading status has changed as above:


this.subscriptions.add(this.personService.updatePerson(this.personId, personobject.list)
      .pipe(
        switchMap(() => {
          this.setPersonUploadStatus(UploadStatus.FinishedSuccessfully);
          this.setPersonsHierarchyUploadStatus(UploadStatus.InProgress);

          return this.personService.updatePersonHierarchy(this.personId, personobject.list).pipe(share());
        }),
        finalize(() => {
          this.setPersonUploadStatus(UploadStatus.NotStarted);
          this.setPersonsHierarchyUploadStatus(UploadStatus.NotStarted);          
        })
      ).subscribe(
        () => {
          this.setPersonUploadStatus(UploadStatus.FinishedSuccessfully);
          this.toastr.success(this.Translations['success']);
        },
        (response) => {
          this.toastr.error(response.error.message, this.Translations['shared.error']);
        }
      ));

private setPersonUploadStatus(uploadStatus: UploadStatus){
    this.personUploadStatus = uploadStatus;
  }

  private setPersonsHierarchyUploadStatus(uploadStatus: UploadStatus) {
    this.personHierarchyUploadStatus = uploadStatus;
  }

below values are inputted to child component where is ngOnChanges method, which not call any change...

personHierarchyUploadStatus
personUploadStatus
ruddnisrus
  • 187
  • 5
  • @Vikas what is not understandable for You? I have two properties which are passed to children , and value of them are changed in parent in switchMap, what is a problem? – ruddnisrus Dec 09 '22 at 09:59
  • I'm also not able to understand what is wrong with that post.. It's clear situation, I know that it will not help You much, but there is a problem witch this switchMap, did You tried to change it for example to mergeMap? – Mateusz Kaleta Dec 09 '22 at 10:09

0 Answers0