Skip to content

Commit

Permalink
feat: better loading
Browse files Browse the repository at this point in the history
  • Loading branch information
maaslalani committed May 9, 2024
1 parent 81c646c commit aac59a2
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions examples/dynamic/dynamic-country/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,24 @@ func main() {
time.Sleep(1000 * time.Millisecond)
return huh.NewOptions(s...)
}, &country /* only this function when `country` changes */),
huh.NewSelect[string]().
Height(8).
TitleFunc(func() string {
switch country {
case "United States":
return "State"
case "Canada":
return "Province"
default:
return "Territory"
}
}, &country).
OptionsFunc(func() []huh.Option[string] {
s := states[country]
// simulate API call
time.Sleep(1000 * time.Millisecond)
return huh.NewOptions(s...)
}, &country /* only this function when `country` changes */),
huh.NewNote().
TitleFunc(func() string {
return fmt.Sprintf("You selected: %s", country)
Expand Down

0 comments on commit aac59a2

Please sign in to comment.