No fun learning es6 version of the javascript updates.
There is so much going on with "new Promise" or indexedDb version "dbPromise" that it's hard to grasp all the process happening around it. Especially the callbacks and/or returns with there own returns and callbacks.
It took me a while but now I feel like, I know enough to understand "es6" "promise" and "then" after completing the course.
The best way to understand how the "resolve and reject" work with "promise" is to work on a sample project or lab.
I was struggling with resolve and no reject, as it was confusing. Could not understand initially as to how the resolve will be returned but a reject will not trigger the failed scenario. Finally realized the sub method was not implemented with the reject logic and thus didn't return the error part of the callback.
It may be easier to understand now regarding promise with return and no returns, dbPromise with valid return and without valid return, callbacks of the callbacks, and the .then (dot then) with return value [ .then((result) => {}) ] vs then with variable initialized before dbPromise or new Promise [ .then(restaurant_id, (result) => {}) ], there is so much that if one doesn't understand the entire concept, it will be very hard to debug the solution.
Oh year, there is also promise version of try-catch with return false or catch with callback" of the methods. The only way all of these will be easier to understand is to have your own debug implementation. My simple console.log debug implementation, made it simple to understand how the code is being triggered and where the underlining issue is, saved me lot of hours.
I am happy to have completed the project and completed the Mobile Web Specialist Nanodegree from Udacity, sponsored by Grow with Google.
There is so much going on with "new Promise" or indexedDb version "dbPromise" that it's hard to grasp all the process happening around it. Especially the callbacks and/or returns with there own returns and callbacks.
It took me a while but now I feel like, I know enough to understand "es6" "promise" and "then" after completing the course.
The best way to understand how the "resolve and reject" work with "promise" is to work on a sample project or lab.
I was struggling with resolve and no reject, as it was confusing. Could not understand initially as to how the resolve will be returned but a reject will not trigger the failed scenario. Finally realized the sub method was not implemented with the reject logic and thus didn't return the error part of the callback.
It may be easier to understand now regarding promise with return and no returns, dbPromise with valid return and without valid return, callbacks of the callbacks, and the .then (dot then) with return value [ .then((result) => {}) ] vs then with variable initialized before dbPromise or new Promise [ .then(restaurant_id, (result) => {}) ], there is so much that if one doesn't understand the entire concept, it will be very hard to debug the solution.
Oh year, there is also promise version of try-catch with return false or catch with callback" of the methods. The only way all of these will be easier to understand is to have your own debug implementation. My simple console.log debug implementation, made it simple to understand how the code is being triggered and where the underlining issue is, saved me lot of hours.
I am happy to have completed the project and completed the Mobile Web Specialist Nanodegree from Udacity, sponsored by Grow with Google.
Comments
Post a Comment