-
Notifications
You must be signed in to change notification settings - Fork 17
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
Rewrite data fetch using async/await. Refs #25 #32
Conversation
Signed-off-by: André Jaenisch <[email protected]>
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.
I was thinking that the whole thing could just avoid using explicit promises and remove the getData
URL entirely, and the main flow would be like:
let response = await window.fetch(url);
if (response.status < 200 || response.status >= 300) {
throw "data fetch failed";
}
// do the rest of the stuff to response.json
like, the only reason getData
existed is to support the XHR polyfill.
Signed-off-by: André Jaenisch <[email protected]>
Signed-off-by: André Jaenisch <[email protected]>
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.
Just a nitpick about a comment that I overlooked earlier, otherwise it's fine
}; | ||
|
||
json.children.forEach(function(child) { | ||
// This seem to push the reaction into either comments or collects |
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.
Make this comment "put the reaction into its appropriate destination"
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.
I've added that comment, because I wasn't quite sure what's going on there.
Feels a bit dirty to have the store
point to the respective object in memory …
=> Another issue?
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.
There is nothing dirty about that pattern. It's simple and straightforward and efficient.
Signed-off-by: André Jaenisch [email protected]
I wasn't sure, how far you want to have async/await applied.
(See also What Color is Your Function?