Conversation
homework/content.js
Outdated
There was a problem hiding this comment.
Instead of using an anonymous function, set the listener as this and handle events with handleEvent method is better.
|
After check, your critical error look the same as 101502012's: Please correct it by yourself. |
|
@snowmantw : I am not really understand what promise code should looked like, so I follow the code on page 93 of slide. So I need to correct the error on Github? Or explain on the class next week? |
|
You only need to correct it on this PR. And the page is not about the error: it is only a general reference for what the flow should look like. The point is you implemented the Promise version of XHR method at line 59, but you still keep the callback style that I expect you to refactor. So you can keep only the Promise pattern, and remove the callback. Also please note the |
There was a problem hiding this comment.
Not sure if this is what Promise code should be like.
My understanding is pulling callback out from the function.
There was a problem hiding this comment.
It's unfortunately wrong. You just got trapped by a common mistake. In fact, you should do this if you don't want to use the plain chaining style:
promise = promise.then(....);
promise = promise.catch(....);
Please note it's because every time the then or catch is called, it will create a new instance of then-able. So if you do this:
promise.then(task1)
promise.then(task2)
It will NOT guarantee task2 is only after task1. In fact, they will execute concurrently. So you must make sure the then-able is updated as I wrote.
review?=@snowmantw
review?=@chungya
review?=@FlowerHop