O'Reilly logo

Programming Elm by Jeremy Fairbank

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Load Multiple Photos

So far, you’ve used a single photo in the application, but it really should have many photos. In this section, you’ll update the application to display multiple photos. You will learn how to search lists in a model and add error handling to the API calls from the previous chapter.

Fetch Multiple Photos

In order to fetch multiple photos, you need to change the model to use a list of photos. First, create a helpful type alias for a list of photos called Feed:

 type​ ​alias​ ​Feed​ =
 List​ ​Photo

Then, replace the photo field in Model and initialModel with a feed field that has the type Maybe Feed:

 type​ ​alias​ ​Model​ =
  { feed : ​Maybe​ ​Feed​ }
 initialModel =
  { feed = ​Nothing​ }

Next, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required