阅读背景:

尽管有希望,javascript promise会同步执行代码

来源:互联网 

so basically i have a web application that retrieves data from firebase. Since it takes time to query, i used promises in javascript so that my code will execute at the right time. In function getDataFirebase, data is retrieved from firebase and is push to an array called Collect. So, after pushing 1 row, it query again to the firebase for another table of data to be collected then continues the loop. So, i create a promise before calling Firebase, and then resolving afterwards. But, im not doing that on getDataUsers.once("value"). There, i'm firing event and not waiting for it to return - the for-loop continues on, and all the callbacks processed later, but resolve is at the end of the for-loop, so its too late by then.so basically i have a web application that retr




你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: