-
Notifications
You must be signed in to change notification settings - Fork 45
102502038 #53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: homework
Are you sure you want to change the base?
102502038 #53
Conversation
homework/content.js
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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