krisajenkins/elm-exts/13.0.0

NOTE: this package is not compatible with Elm 0.19.1

Exts.RemoteData

A datatype representing fetched data.

type RemoteData a
= NotAsked
| Loading
| Failure Error
| Success a

Frequently when you're fetching data from an API, you want to represent four different states: * NotAsked - We haven't asked for the data yet. * Loading - We've asked, but haven't got an answer yet. * Failure - We asked, but something went wrong. Here's the Error. * Success - Everything worked, and here's the data.

map : (a -> b) -> RemoteData a -> RemoteData b

Map a function into the Success value.

withDefault : a -> RemoteData a -> a

Return the Success value, or the default.

fromResult : Result Error a -> RemoteData a

Convert a Result Error, probably produced from elm-http, to a RemoteData value.

asEffect : Task Error a -> Effects (RemoteData a)

Convert a web Task, probably produced from elm-http, to a RemoteData Effect.

mappend : RemoteData a -> RemoteData b -> RemoteData ( a, b )

Monoidal append - join two RemoteData values together as though they were one. If both values are Failure, the left one wins.

isSuccess : RemoteData a -> Bool

State-checking predicate. Returns true if we've successfully loaded some data.