Why Do We Have To Call `.done()` At The End Of A Promise Chain In React-native?
In the react-native tutorial it says: Note that we call done() at the end of the promise chain - always make sure to call done() or any errors thrown will get swallowed. fetch
Solution 1:
What I needed clarified:
- Exceptions encountered in promises (during execution of the
then()
callback) are stored as anError
object, and not thrown.
This mechanism means that you can defer actions without risk of exceptions inside them messing you up at a random time.
done()
called without argument on a promise looks into the promise to see if there are any stored exceptions, and throws them.
This means that you can take care of exceptions during promise processing, at the end of the promise processing.
Post a Comment for "Why Do We Have To Call `.done()` At The End Of A Promise Chain In React-native?"