Thanks for the video Doug. Good to see you're back from your Google Tel-Aviv improvised office, although your view there was better looking than the green screen backdrop :-)
When I do this I get red underlines in the editor when trying to access anything after snapshot.data(). I get an "Object is possibly 'undefined'" error. What am I doing wrong? Code and data structure is identical.
to ignore errors like ' Object is possibly 'undefined'.' : go to tsconfig.json and add "strictNullChecks":false * credit to a comment of ralbertini on github *
Once again, absolutely brilliant! And very appreciative that you delivered on the time you committed. Admirable!! But i still have 1 nagging problem. Inside my forEach there are processes where I need to use AWAIT. So, I made the forEach async. But it doesn't run more than once. Some say use "await Promise.all' with snapshot.map(...). What's your best advice on handling a snapshot.forEach loop when there are AWAIT promises in every iteration?
Do you really need to wait for each one in sequence, or can you do them all in parallel like my example? If you must wait for each one separately, try switching to a for loop (or something that doesn't take a lambda function as a callback). stackoverflow.com/questions/37576685/using-async-await-with-a-foreach-loop
Cloud Functions currently runs node 6, which does not support ECMAScript 2017 async/await, which means you can't use it in JavaScript. When the runtime is upgraded to node 8, you will be able to. I don't know when that will be. For now, you have to use a transpiler.
thanks for the reply, I'm currently migrating from javascript to typescript in order to use async/await. just an issue not related to this post, I think. I need to delete multiple data as link below, but it only provide node.js code not in typescript. is it not necessary to use process.nextTick (only can use in javascript) anymore? With async/await, is it already solve the stack problem? firebase.google.com/docs/firestore/manage-data/delete-data
Hi Doug, some of the functions samples (like the audio ffmpeg conversion) still has the .js examples. Are there any plans to revamp the github examples to reflect .ts? Many thanks.
BTW..forgot... PLS, more of the same! Also hope you can do an extensive and in depth on Firestore rules. I know there is some available..but..:-)..and as U say...Firestore/base there are NO substitutes...
Any advice on using async/await with batched transactions via firestore.runTransaction( transaction => {...} )? I've been trying to figure this out, but my head is about to explode. Thanks in advance if you have time to help! Great video, btw! I have learned a lot watching this and your previous videos.
It sounds like you might want to post your question to Stack Overflow so you have more space to explain in more detail what problem you're running into.
Thanks for the quick response. I actually just got it working! Still testing, though, so I may still have to go the Stack Overflow route. Wish me luck!
You might find what you are looking for in the following link rnfirebase.io/docs/v4.0.x/firestore/transactions A little late but hope this helps others
Variable 'promises' implicitly has type 'any[]' in some locations where its type cannot be determined, and areaSnapshot 'Object is possibly 'undefined'. How do I fix these errors?
Great video. From your example I tried working on an example which calls a function that returns a promise and I am trying to populate a variable but getting empty string outside of the async function. let DatafromPromise = {}; const loadDataPromise = async () => { //async keyword added before the function, you can indicate that the function always returns a promise try { const myPromise = await getDataFromFile( ); // This returns a promise. DatafromPromise = myPromise.value; // When it awaits from above line I want to get the data value //console.log(DatafromPromise); // I see data here. } catch (error) { console.log(error); } }; loadDataPromise(); // I am a bit confused, Is this returning a promise too? console.log("SelectedDate " + SelectedDate); console.log(DatafromPromise); // this is coming out empty
#Error - "Object is possibly 'undefined'.ts(2532)" error on line 9 - "Variable 'results' implicitly has type 'any[]' in some locations where its type cannot be determined.ts(7034)" error on line 17 and - "Variable 'results' implicitly has an 'any[]' type.ts(7005)" on line 23 Anyone have the same problem or can help?
I got an error when I declare cloud function like this: exports.updateFriends = functions.https.onCall(async (data, context) => {...}) error Parsing error: Unexpected token => does anybody know?
The examples are kept simple here because many people following these tutorials have little to no JavaScript or functional programming experience, coming from Android or iOS backgrounds. For anyone who understands loops, foreach needs no explanation. But I can't say the same about map. :-(
This video solves exactly the questions I was having lol. Great work
Very, very good video series. HIGH QUALITY, right on target!
3.47 onwards is what I was looking for. Thank you, Doug.
Firebase + Typescript 🔥
Wow. Nicely explained. I finally get it now. I like the refactoring part. Thank you.
So glad you found it helpful!
That's super nice, the code looks a lot cleaner, thanks for the tip!
This is a great video. And an area where TypeScript adds a lot of clarity to the development process.
Loving these series! I had some doubts with Promises, now i know what i needed :) Thanks!
Just wanted to say thanks! This was a very helpful series
It's really clear and useful. Save a lot of time for beginners like me.
Thanks for the video Doug. Good to see you're back from your Google Tel-Aviv improvised office, although your view there was better looking than the green screen backdrop :-)
Maybe future firecasts should appear to come from exotic locations all over the world!
For whatever it counts, I'm up for Async/await pt.3 from Bora Bora? Shall I start gofundme 2 cover the trip?
I'm not one to turn down free money.
Awesome video! Exactly what I needed today to refactor some code. Keep these up
Thank you Doug! I digged a lot your playlist!
This video series helped me a lot! Thank you!!!
amazing explanation! Congratulation!! and Thank you very much!
How do you deal with the "snapshot.forEach" as specified in the documentation, because I am having problems with async await using that.
incredibly educating video.
When I do this I get red underlines in the editor when trying to access anything after snapshot.data(). I get an "Object is possibly 'undefined'" error. What am I doing wrong? Code and data structure is identical.
to ignore errors like ' Object is possibly 'undefined'.' :
go to tsconfig.json and add "strictNullChecks":false
* credit to a comment of ralbertini on github *
It will be enough to use null coalescing, like this: areaSnapshot.data()?.cities
Awesome teacher!
Once again, absolutely brilliant! And very appreciative that you delivered on the time you committed. Admirable!!
But i still have 1 nagging problem. Inside my forEach there are processes where I need to use AWAIT. So, I made the forEach async. But it doesn't run more than once. Some say use "await Promise.all' with snapshot.map(...).
What's your best advice on handling a snapshot.forEach loop when there are AWAIT promises in every iteration?
Do you really need to wait for each one in sequence, or can you do them all in parallel like my example? If you must wait for each one separately, try switching to a for loop (or something that doesn't take a lambda function as a callback).
stackoverflow.com/questions/37576685/using-async-await-with-a-foreach-loop
Thanks bro, you're a true Gem!
Ok, loads of reading & trying stuff out... Will let you know what worked best.
Thanks a million again :-)
How is the javascript? cause currently I can't use async/await for javascript in cloud functions.
Cloud Functions currently runs node 6, which does not support ECMAScript 2017 async/await, which means you can't use it in JavaScript. When the runtime is upgraded to node 8, you will be able to. I don't know when that will be. For now, you have to use a transpiler.
thanks for the reply, I'm currently migrating from javascript to typescript in order to use async/await.
just an issue not related to this post, I think.
I need to delete multiple data as link below, but it only provide node.js code not in typescript.
is it not necessary to use process.nextTick (only can use in javascript) anymore?
With async/await, is it already solve the stack problem?
firebase.google.com/docs/firestore/manage-data/delete-data
If you have a programming question, I think it would be better to ask on Stack Overflow.
ok
video tips using async/await for realtime database transaction also for firestore runTransaction in cloud functions.
Gracias amigo!!!
Hi Doug, some of the functions samples (like the audio ffmpeg conversion) still has the .js examples. Are there any plans to revamp the github examples to reflect .ts? Many thanks.
thanks, very useful
BTW..forgot... PLS, more of the same! Also hope you can do an extensive and in depth on Firestore rules. I know there is some available..but..:-)..and as U say...Firestore/base there are NO substitutes...
Any advice on using async/await with batched transactions via firestore.runTransaction( transaction => {...} )? I've been trying to figure this out, but my head is about to explode. Thanks in advance if you have time to help!
Great video, btw! I have learned a lot watching this and your previous videos.
It sounds like you might want to post your question to Stack Overflow so you have more space to explain in more detail what problem you're running into.
Thanks for the quick response. I actually just got it working! Still testing, though, so I may still have to go the Stack Overflow route. Wish me luck!
You might find what you are looking for in the following link
rnfirebase.io/docs/v4.0.x/firestore/transactions
A little late but hope this helps others
Why would one use async/await vs then().catch()? Isn't the latter easier to test?
Variable 'promises' implicitly has type 'any[]' in some locations where its type cannot be determined, and areaSnapshot 'Object is possibly 'undefined'. How do I fix these errors?
Great video. From your example I tried working on an example which calls a function that returns a promise and I am trying to populate a variable but getting empty string outside of the async function.
let DatafromPromise = {};
const loadDataPromise = async () => {
//async keyword added before the function, you can indicate that the function always returns a promise
try {
const myPromise = await getDataFromFile(
); // This returns a promise.
DatafromPromise = myPromise.value;
// When it awaits from above line I want to get the data value
//console.log(DatafromPromise);
// I see data here.
} catch (error) {
console.log(error);
}
};
loadDataPromise();
// I am a bit confused, Is this returning a promise too?
console.log("SelectedDate " + SelectedDate);
console.log(DatafromPromise); // this is coming out empty
Awesome. Thank you :)
#Error
- "Object is possibly 'undefined'.ts(2532)" error on line 9
- "Variable 'results' implicitly has type 'any[]' in some locations where its type cannot be determined.ts(7034)" error on line 17
and
- "Variable 'results' implicitly has an 'any[]' type.ts(7005)" on line 23
Anyone have the same problem or can help?
I have this. Did you resolved ?
nice one! Thanks
can you make onCall request of firebase cloud functions?
wich´s the version what you use ?
The version of what?
super!
I got an error when I declare cloud function like this:
exports.updateFriends = functions.https.onCall(async (data, context) => {...})
error Parsing error: Unexpected token =>
does anybody know?
Great!
Can you use aync/await on .onSnapshot?
You can use async on the callback you pass to it, but onSnapshot doesn't return a promise, so you can't await it.
@@dougstevenson3769 I need to filter the items from onSnapshot and remove duplicate items after it's finished. What would be a good strategy for that?
You should probably use Array.prototype.map at 5:08
The examples are kept simple here because many people following these tutorials have little to no JavaScript or functional programming experience, coming from Android or iOS backgrounds. For anyone who understands loops, foreach needs no explanation. But I can't say the same about map. :-(
Okay then :-)
Nice !
Easier is impossible !