|
1 | 1 | # Homework Week 2 |
2 | 2 |
|
3 | | -``` |
4 | | -Topics discussed this week: |
5 | | -• Async vs Sync |
6 | | -• Event Loop (order of execution) |
7 | | -• Promises |
8 | | -``` |
9 | | - |
10 | | -## Step 1: Read |
| 3 | +## Part 1 <small>- Reading material</small> |
11 | 4 |
|
12 | | -- Read this article on scopes & closures: [explaining-javascript-scope-and-closures](https://robertnyman.com/2008/10/09/explaining-javascript-scope-and-closures/) |
| 5 | +- [ ] Read this article on scopes & closures: [Explaining javascript scope and closures](https://robertnyman.com/2008/10/09/explaining-javascript-scope-and-closures/) |
13 | 6 |
|
14 | | -- If you are still not completely clear on promises, here are some additional resources :ring: |
| 7 | +- [ ] If you are still not completely clear on promises, here are some additional resources: |
15 | 8 |
|
16 | 9 | - [Google's post about Promises](https://developers.google.com/web/fundamentals/getting-started/primers/promises) |
17 | 10 | - [A nice article from David Walsh](https://davidwalsh.name/promises) |
18 | 11 | - [A real life example](https://github.com/mdn/js-examples/blob/master/promises-test/index.html) |
19 | 12 | - [stackoverflow](http://stackoverflow.com/questions/13343340/calling-an-asynchronous-function-within-a-for-loop-in-javascript) |
20 | 13 | - YouTube: [promises](https://www.youtube.com/watch?v=WBupia9oidU) |
21 | 14 |
|
22 | | -## Step 2: Implement requested PR changes |
| 15 | +## Part 2 <small>- Finish last week's homework</small> |
| 16 | +**Deadline: Tuesday evening** |
23 | 17 |
|
24 | | -- Fix Requested Changes (if any) on the Pull Request. |
| 18 | +This week's homework builds upon last week's homework. So if you haven't already, finish last week's homework first, by following the [complete guide](../week1/MAKEME.md), step-by-step. If you want some intermediate comments/review after finishing that, go a head and already send it in with a pull request, as described there. Or you may immediately add this week's work. |
25 | 19 |
|
26 | | -## Step 3: Convert callbacks to promises |
| 20 | +## Part 3 <small>- Setup for this week</small> |
| 21 | +**Deadline: Thursday evening** |
27 | 22 |
|
28 | | -**_Deadline Thursday_** |
| 23 | +Create a new branch based on the `week1` branch: |
29 | 24 |
|
30 | | -### 3.1 Preparation |
31 | | - |
32 | | -The homework for week 2 will build on the work you did in week 1. You will create a new branch based on the `week1` branch. |
33 | | - |
34 | | -1. Make sure that you committed all changes in the week 1 version of your homework. |
35 | | -2. Create a new `week2` branch: |
| 25 | +- [ ] Make sure that you committed all changes in the week 1 version of your homework. |
| 26 | +- [ ] Create a new `week2` branch: |
36 | 27 |
|
37 | 28 | ``` |
38 | 29 | git checkout -b week2 |
39 | 30 | ``` |
40 | 31 |
|
41 | | -### 3.2 Assignment |
| 32 | +## Part 4 <small>- This week's assignment</small> |
| 33 | +**Deadline: Tursday evening** |
| 34 | + |
| 35 | +You will continue to work on the files `index.js` and (possibly) `main.css`. |
42 | 36 |
|
43 | | -You will continue to work on the files `index.js` and (possibly) `style.css`. |
| 37 | +- [ ] Upon selecting a repository, also load that repository's list of **contributers**, and display it, at least using the contributor's profile picture, name, and amout of repositories. |
| 38 | + > *Hint*: As we saw last week, the link to the repo's contributors is a property of a repo. |
44 | 39 |
|
45 | | -- Complete your GitHub app code from the previous week, if needed, to meet the requirements from that week's assignment. |
46 | | -- Replace all asynchronous callbacks (e.g. as used with XMLHttpRequest) by ES6 promises. |
47 | | -- Beautify your app's styling. |
48 | | -- If not yet completed in week 1, make your app responsive (use CSS media queries and [Flexbox](https://css-tricks.com/snippets/css/a-guide-to-flexbox/)). |
| 40 | +- [ ] Clicking on the user should open this user's GitHub home page in a new tab. |
| 41 | + > *Hint*: `target` |
49 | 42 |
|
50 | | -### 3.3 Handing in your homework |
| 43 | +- [ ] When loading the repositories initially, and when loading the contributors after selecting a repo: display a 'loading' text or 'spinner'. Remove it once the data is loaded and displayed (or when an error occurs). |
| 44 | + > *Hint*: In Chrome DevTools, in the Network tab, you can simulate a 'Slow 3G' connection to test your loading text/spinner. |
| 45 | + >  |
| 46 | +
|
| 47 | +- [ ] When any error occurs - either when [fetching](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) the repos or when loading contributers, clearly display a nice error message somewhere on the page. |
| 48 | + > *Hints*: |
| 49 | + > |
| 50 | + >- `fetch` will not `reject` on a 404; not even on a 500; it will actually *succeed* (resolve). You have to check the result's `status` to see whether its response has a statuscode in the 200-range. |
| 51 | + > |
| 52 | + > Give it a try - this will actually log the success! |
| 53 | + > |
| 54 | + > ``` |
| 55 | + > fetch('this-isnt-even-a-proper-url') |
| 56 | + > .then((resp) => console.log('success', resp)) |
| 57 | + > .catch((err) => console.error('error', err)); |
| 58 | + > ``` |
| 59 | + > `fetch` will only *reject* when there is really a network error, like when you're offline. |
| 60 | + >- You can re-use a function you pass as callback to `then`! |
| 61 | + >- Test this by changing your fetch urls, and by simulating having no internet. You can do this in DevTools, in the Network tab: |
| 62 | + >  |
| 63 | +
|
| 64 | +- [ ] If not yet completed in week 1, make your app responsive. Use CSS media queries and [Flexbox](https://css-tricks.com/snippets/css/a-guide-to-flexbox/)). |
| 65 | +
|
| 66 | +## Part 5 <small>- Handing in your homework</small> |
| 67 | +**Deadline: Thursday evening** |
51 | 68 |
|
52 | 69 | If necessary, review the instructions how to [Hand in homework](https://github.com/HackYourFuture/fundamentals/blob/master/fundamentals/homework_pr.md) using GitHub pull request. |
53 | 70 |
|
@@ -78,8 +95,4 @@ If the answer is 'yes' to the preceding questions you are ready to follow these |
78 | 95 | Note: |
79 | 96 |
|
80 | 97 | 1. Please remove all redundant, commented-out code and console.log's from your files before pushing your homework as finished. There is no need for your mentors to review this stuff. |
81 | | -2. Please make sure your code is well-formatted and follows the recommended naming conventions. |
82 | | - |
83 | | -## Step 4: Read before next lecture |
84 | | - |
85 | | -Go through the reading material in the [README.md](../Week3/README.md) to prepare for your next class. |
| 98 | +2. Please make sure your code is well-formatted and follows the recommended naming conventions. |
0 commit comments