React-native地图正在等待promise.all

时间:2018-11-27 08:03:08

标签: javascript react-native

本机,我曾经尝试过使用await和.then,但是当我运行代码时,它将直接跳转到dispatch(successGetPostList)

 userRef = firestore.collection('user')
            const postList = []
            await Promise.all(user.userFollowing.map(async (val) => {
                postRef = firestore.collection('post').where('postOwner', '==', firestore.collection('user').doc(val))
                await postRef.onSnapshot(async (collection) => {
                   await Promise.all(collection._docs.map(async (doc) => {
                           let post =doc.data()
                         await post.postOwner.get().then((user)=>{
                             let owner={
                                 ...user.data()
                             }
                             post ={
                                 ...post,
                                 postId:doc.id,
                                 owner:owner
                             }
                             postList.push(post)
                            })
                        }))
                    })
                }))
                dispatch(_successGetPostList(postList))

0 个答案:

没有答案