Created
November 2, 2017 18:24
-
-
Save toretore/548010be57a8fd246b46e8fea0d474b4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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