async setMyPhotos() {
const newPhotos = await Promise.all(newPhotoPromises);
someOtherPromise(); // will wait for newPhotoPromises
syncAvatar(newPhotos[0], function(res, err) { // does this wait for newPhotoPromises too?
if (!err) console.log("avatar sync'd");
});
return newPhotos; // return just needs to wait for newPhotoPromises
}
I noticed syncAvatar
seems to work, but I'm not sure if I'm just getting lucky or not. If so, how do I make sure syncAvatar
only runs after newPhotoPromises
are done?
To clarify, syncAvatar
needs to happen after newPhotoPromises
are done, however setMyPhotos
just needs to return the results of newPhotoPromises
, while syncAvatar
can happen in the background.