I'm looking at firebase sdk and there is a line where the getAuth token method returns a Promise that resolves to null? I've seen this pattern a few times and am confused what the purpose of this is.
https://github.com/firebase/firebase-js-sdk/blob/ee610626bef1f6f05852041b2161c01c5e99aa59/packages/app/src/firebaseApp.ts#L67
I know this is an old question. But thought it worth mentioning. Promise.resolve(null) immediately resolves the promise, but the delegate you pass to .then(()=> {}) on the returned Promise will be placed on the microtask queue. Similar to window.setTimeout(()=> {}, 0); (not exactly the same, but very similar).
I've seen this documented on MDN, but I cannot find the page now. If anyone does find that page feel free to edit my answer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With