Improve some comments

This commit is contained in:
Christian Rocha 2020-06-24 12:14:35 -04:00
parent e90039d16e
commit f3fd9decc9
No known key found for this signature in database
GPG Key ID: D6CC7A16E5878018
1 changed files with 10 additions and 6 deletions

16
tea.go
View File

@ -16,9 +16,12 @@ type Msg interface{}
// Model contains the program's state. // Model contains the program's state.
type Model interface{} type Model interface{}
// Cmd is an IO operation. If it's nil it's considered a no-op. Keep in mind // Cmd is an IO operation. If it's nil it's considered a no-op. Use it for
// that there's almost never a need to use a command to send a message to // things like HTTP requests, timers, saving and loading from disk, and so on.
// another part of your program. //
// There's almost never a need to use a command to send a message to another
// part of your program. Instead, it can almost always be done in the update
// function.
type Cmd func() Msg type Cmd func() Msg
// Batch peforms a bunch of commands concurrently with no ordering guarantees // Batch peforms a bunch of commands concurrently with no ordering guarantees
@ -36,11 +39,12 @@ func Batch(cmds ...Cmd) Cmd {
// model and runs an optional command. // model and runs an optional command.
type Init func() (Model, Cmd) type Init func() (Model, Cmd)
// Update is called when a message is received. It may update the model and/or // Update is called when a message is received. Use it to inspect messages and,
// send a command. // in repsonse, update the model and/or send a command.
type Update func(Msg, Model) (Model, Cmd) type Update func(Msg, Model) (Model, Cmd)
// View produces a string which will be rendered to the terminal. // View renders the program's UI: a string which will be printed to the
// terminal. The view is rendered after every Update.
type View func(Model) string type View func(Model) string
// Program is a terminal user interface. // Program is a terminal user interface.