amilner42 / code-tidbit

Share Programming Knowledge Better
GNU General Public License v3.0
9 stars 1 forks source link

165 api tracker #183

Closed amilner42 closed 7 years ago

amilner42 commented 7 years ago

Closes

Closes #165

Description

I realized I have to give a shit about possible network latency, so:

  1. Added flag to backend, --slow-network, can only be run in development mode, which will create a fake slow network. This is a base latency + some random initial latency (spotty networks).

  2. Created a module, RequestTracker, which creates a primitive system for keeping track of requests. Added helpers makeSingletonRequest and andFinishRequest for starting/ending requests.

  3. Fixed most areas of the website that had bugs on a slow-network by simply not allowing multiple requests and adding a cursor spinner or other UX to let the user know the request is in progress.

  4. For the browse page, instead of just not allowing multiple requests, we allow multiple search requests but we only care about the results of the most recent request. We also don't allow identical search requests at the same time as per usual. This allows the user to make a search request, and before it returns, realize they want to change the search, and make a new request without having to wait for the last request to finish.