Skip to content
Myr

Friendlier headers in the basics tutorial

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Christian Rocha · committed by Christian Rocha · parent 7e36944 · Browse files · 2 files+6 added−6 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+6 added−6 removed

  • other:+6 added−6 removed

2 files+6 added−6 removed

modified:tutorials/basics/README.md+5 added-5 removed
49 unmodified lines
50 selected map[int]struct{} // which to-do items are selected51 }52```5354## Initialize54## The Initialization Function5556Next we'll define a function that will initialize our application. An57initialize function returns a model representing our application's initial58state, as well as a `Cmd` that could perform some initial I/O. For now, we
17 unmodified lines
76 return m, nil77 }78```7980## Update80## The Update Function8182Next we'll define the update function. The update function is called when83"things happen." It's job is to look at what has happened and return an updated84model in response to whatever happened. It can also return a `Cmd` and make
61 unmodified lines
146You may have noticed that "ctrl+c" and "q" above return a `tea.Quit` command147with the model. That's a special command which instructs the Bubble Tea runtime148to quit, effectively exiting the program.149150## The View150## The View Function151152At last, it's time to render our UI. Of all the functions, the view is the153simplest. A model, in it's current state, comes in and a `string` comes out.154That string is our UI!
35 unmodified lines
190 return s191 }192```193194## All together now194## All Together Now195196The last step is to simply run our program. We pass our functions to197`tea.NewProgram` and let it rip:198
6 unmodified lines
205 }206 }207```208209## What's next?209## What's Next?210211This tutorial covers the basics of building an interactive terminal UI, but212in the real world you'll also need to perform I/O. To learn about that have a213look at the [Cmd Tutorial][cmd]. It's pretty simple.
33 unmodified lines
modified:tutorials/commands/README.md+1 added-1 removed
195 unmodified lines
196```197198Just make sure you do as much work as you can in the innermost function, because199that's the one that runs asynchronously.200200n201## Anyway, Now What?202203After doing this tutorial and [the previous one][basics] you should be ready to204build a Bubble Tea program of your own. We also recommend that you look at the
34 unmodified lines