Skip to content

Flaky Network

You'll pull live data from a public API and make every screen behave on a slow connection, with no connection, and when the server answers with an error.

About

On a laptop the network is always there. On a phone it comes and goes in a lift, a train and a basement, and an app that shows a blank screen while it waits reads as broken. Every screen that loads data has four states, loading, loaded, empty and failed, and you build all four on purpose. Use a free public API that needs no key, like Open-Meteo for weather or the Open Library for books. Both platforms give you a throttle: an iPhone has Network Link Conditioner under the Developer settings once you've run a build on it, and the Android emulator has a network speed setting. Airplane mode on any phone is the free one.

At a glance

Per requirement
25 XP
Completion bonus
150 XP
Requirements
6
Takes
One weekend
Skill level
Intermediate (months of practice)
Cost
Free
Supplies
Nothing special
Where
At home
Other people
On your own
Locked for now
Earn two more Common badges in Mobile Apps to open this one. Log in to see how far along you are.

Requirements

  1. 1
    Fetch from a public API and show the result on screen. Decode the JSON into a typed model rather than digging through dictionaries, so a changed field fails in one place with a clear message. Take a photo of the screen with live data and the phone's clock showing. Photo
  2. 2
    Show a loading state that doesn't block the rest of the app. Skeleton rows or a spinner inside the content area, with the navigation still usable. Throttle the connection to 3G, or stand in the basement. Film the loading state on the real phone. Video
  3. 3
    Show an error with a retry button when the request fails. The message should say what happened in a sentence someone who isn't a programmer understands, not the exception text. Film airplane mode on, the error, airplane mode off, and retry bringing the data back. Video
  4. 4
    Cache the last good response so the app opens with content offline. Store the last result on disk with its timestamp, show it with a last-updated line, and refresh in the background when the network is back. Film a cold start in airplane mode showing the cached data and its time. Video
  5. 5
    Handle a slow response without firing twice. Pull to refresh twice in a row and send one request, and cancel the request in flight when you leave the screen. Film the double pull with the network throttled and the request log showing one call. Video
  6. 6
    Tell an empty answer apart from a server error. A search with no results isn't a failure, so it gets a plain sentence and no retry button. A 500 from the server is, so point the app at a URL you've deliberately broken, or a route that returns one, and show it landing on the error state rather than crashing. Post a photo of the two screens and tell us what the server actually returned. Photo