2021年4月5日星期一

Subscription getting too late in the execution angular

I'm new to angular and my subscription getting late in execution. I can't use Async Pipes as I'm using custom libraries in my project. here is the subscription function.

loadOrganizations() {      console.log("loading organizattions");      this.getOrganizations().subscribe(        (results) => {          const organizationList = [];          if (results.organizations) {            results.organizations.forEach((element) => {            this.appendOrganization(element, organizationList);              this.loadChildrenOrganization(element.children, organizationList);            });          }                    this.organizations$.next(organizationList);         this.organizations$.complete();         console.log('organizationList in here', organizationList);          return this.organizations$.asObservable();        },        (error) => {          this.organizations$.next([]);          this.organizations$.complete();        }      );    }  

any clue or suggestions to execute this before executing the next lines. I'm calling this function in my authguard.ts inorder to call this function before initializing my component.

https://stackoverflow.com/questions/66962213/subscription-getting-too-late-in-the-execution-angular April 06, 2021 at 11:08AM

没有评论:

发表评论