Component-1在订阅中获得调用时具有方法A,我需要数组列表来检查某些条件,这些条件仅从component-2中的方法Z获得。数据将从DB中获取,因此我需要等待Method-A条件调用,直到arraylist将获得。
这里,checkArrayList()是一种检查数组列表将获取数据的天气的方法。在method-z调用中this.shareDataService.isLoading标志为true / false。从数据库加载数据时,this.shareDataService.arrayList将被更新。
let checkArrayList = async isLoad => {
do {
isLoad = this.shareDataService.isLoading;// true/false in method-z
if (isLoad) {
await new Promise(r => setTimeout(r, 500))
} else {
console.log(this.shareDataService.arrayList); // data will get here
}
}
while (isLoad) //when isload false while loop will break.
}
checkArrayList(this.shareDataService.isLoading); // calling function in method-A