portermichael / portfolio

This is a portfolio project made to showcase blog posts and github work. I'm currently building a jekyll blog to replace this.
https://mike-porter-portfolio.herokuapp.com/
0 stars 0 forks source link

Class 06 #10

Closed portermichael closed 7 years ago

portermichael commented 7 years ago

How long the assignment took. A reflection on the assignment. For example, what was most challenging or interesting your process.

I spend about two productive hours on it.

I wanted to talk out the assignment and what we were doing with people, so I talked with Samantha, Scott and Megan about scaffolding and how we are handling data/what we are doing with it and handling asynchronous data handling. That was the best part of the assignment.

If I were to summarize it here, we are storing our data in JSON. We then use .fetchAll to make an ajax request to get our data. To accomplish the stretch goal we used the method: 'HEAD'. On success we define an eTag based using xhr.ResponseHeader(ETag) and run an if else statement to handle whether we have an eTag property of local storage or not. If we do, we have an eTag and we JSON.parse the local storage property before calling load and initialize on the page. Else we make a $.getJSON request to our data, JSON.stringify the data to store it in our localstorage, define the eTag and store that in local storage and call load/initialize on the page.

The trick is that because things happen asynchronously, we need things to freeze things while we wait for our AJAX response. Otherwise we would run our other functions down the page while we are waiting for the AJAX response. The purpose of initIndexPage is to stall hold the functions until the ajax method is called. Alternatively we could call them all in the fetchAll function, but it just makes things look overwhelming.