Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
module Location
type Location
= None
| SelectCountry (List Country)
| CountrySelected Country
| SelectRegion Country (List Region)
| RegionSelected Country Region
| SelectCity Country Region (List City)
| Complete Country Region City
type Msg
= CountriesLoaded (List Country)
| CountrySelected Country
| RegionsLoaded Country (List Region)
| RegionSelected Country Region
| CitiesLoaded Country Region (List City)
| CitySelected Country Region City
init : (None, getCountries)
forward : Msg -> Location -> (Location, Cmd Msg)
forward msg location =
case msg of
CountriesLoaded cs -> (SelectCountry cs, Cmd.none)
CountrySelected c -> (CountrySelected c, getRegions c)
RegionsLoaded c rs -> (SelectRegion c rs, Cmd.none)
RegionSelected c r -> (RegionSelected c r, getCities c r)
CitiesLoaded c r cs -> (SelectCity c r cs, Cmd.none)
CitySelected co r ci -> (Complete co r ci)
getCountries : Cmd (CountriesLoaded (List Country))
getRegions : Country -> Cmd (RegionsLoaded Country (List Region))
getCities : Country -> Region -> Cmd (CitiesLoaded Country Region (List City))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment